1

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

which of these 2 can do this?

user571099
  • 1,491
  • 6
  • 24
  • 42

1 Answers1

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")
%>
Kane
  • 16,471
  • 11
  • 61
  • 86
  • You can also stream the file to the user to force download. Combine it with a javascript front end that makes an ajax call to create the file, and you have a good example . – Frank Jun 25 '12 at 14:07