1

是否可以“即时”创建一个文本文件,然后要求客户下载它?

我只有两个可用的选项:1. javascript 2. asp classic

这两个中的哪一个可以做到这一点?

4

1 回答 1

1

You can use classic ASP by creating a text file on disk then redirecting to the text file. Note that the file in this example test.txt is created in the folder where the page lives (E.G., \inetpub\wwwroot, etc.)

<%
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")
%>
于 2012-06-25T03:21:38.300 回答