Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Downloading files from an .ASP page
Message
From
26/09/2000 05:24:05
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
 
 
To
25/09/2000 11:05:57
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
General information
Forum:
Internet
Category:
Active Server Page
Miscellaneous
Thread ID:
00420460
Message ID:
00420798
Views:
13
>I'm creating an ASP application, and I want to be able to call a page, with parameters, and have it download a file based on the parameters passed.
>
>The problem that I have, is that I want IE/Netscape to use the correct filename when prompting to save the file.
>
>This works for downloading the file, but the browser always tries to save it with the name of the ASP page.
>
>'---------------------
>'DLTEST.ASP
>Dim fso, f1, ts, lcFile, lcData
>lcFile = "c:\excelfile.xls"
>
>Response.Buffer = TRUE
>
>'Read the file using FSO
>Set fso = CreateObject("Scripting.FileSystemObject")
>Set ts = fso.OpenTextFile(lcFile, 1)
>lcData = ts.ReadAll
>
>'Write the file
>Response.ContentType = "application/octet-stream"
>Response.BinaryWrite lcData
>
>SET ts = NOTHING
>SET FSO = NOTHING
>
>Response.end
>'------------------
>
>Any suggestions greatfully accepted.

Solved it myself.

FYI, You need to use Response.AddHeader to add a Content-Disposition header with a filename=NameToUse value.
Regards
Mark

Microsoft VFP MCP
Menulib - OO Menus for VFP www.hidb.com/menulib
Previous
Reply
Map
View

Click here to load this message in the networking platform