[英]create text file on the fly and ask user to download
is it possible to create a text file "on the fly" and then ask the client to download it? 是否可以“即时”创建文本文件,然后要求客户端下载它?
i only have two options available to me: 1. javascript 2. asp classic 我只有两个选择:1. javascript 2. asp classic
which of these 2 can do this? 这2个中的哪个可以做到这一点?
You can use classic ASP by creating a text file on disk then redirecting to the text file. 您可以通过在磁盘上创建文本文件然后重定向到该文本文件来使用经典ASP。 Note that the file in this example test.txt
is created in the folder where the page lives (EG, \\inetpub\\wwwroot, etc.) 请注意,在此示例test.txt
中的文件是在页面所在的文件夹(EG,\\ inetpub \\ wwwroot等)中创建的
<%
Dim fs, fname
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set fname = fs.CreateTextFile(Server.MapPath("test.txt"), true)
fname.WriteLine("Hello World!")
fname.Close
Set fname = Nothing
Set fs = Nothing
Response.Redirect("text.txt")
%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.