Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Downloading files from an .ASP page
Message
De
26/09/2000 05:24:05
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, Royaume Uni
 
 
À
25/09/2000 11:05:57
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, Royaume Uni
Information générale
Forum:
Internet
Catégorie:
Active Server Page
Divers
Thread ID:
00420460
Message ID:
00420798
Vues:
12
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform