salam
ok ppl, my question is that how to force the web browser to initiate a file download (that save/open dialog box) programmatically from a server side script.
for example, there are different users visiting a site, and now i want to send a user a particular file which could be written/ generated on the fly, means there is no link for the file like "http://www.mydomain.com/myfile.exe" the downloaded file could of any type
i've tried the following asp script:
when the script is called, it displays the desired dialog but when i open the downloaded file, it is corrupt
, i tried bmp, and it came allll black, i tried exe, and when i run it opened that dos prompt window and terminated itself even the exe file downloaded was a valid windows application with a proper gui
i know u will tell me to search it on web, i've tried a lil bit and found similar solutions
can anybody plz tell me is there anything wrong with the above script which i'm using, the header the method of writing the file back to client or anything
thnx in advance
raheel
ok ppl, my question is that how to force the web browser to initiate a file download (that save/open dialog box) programmatically from a server side script.
for example, there are different users visiting a site, and now i want to send a user a particular file which could be written/ generated on the fly, means there is no link for the file like "http://www.mydomain.com/myfile.exe" the downloaded file could of any type
i've tried the following asp script:
PHP Code:
dim fileToDownload
dim outputString
dim fso
dim myFile
fileToDownload = "test.exe"
response.buffer=TRUE
' write header for application type
response.ContentType="application/unknown"
Response.AddHeader "Content-Disposition", "filename=" & fileToDownload
' open the file in text formate
Set fso = createobject("scripting.filesystemobject")
Set myFile = fso.opentextfile( server.MapPath(fileToDownload), 1, false)
' loop and write
Do While Not myFile.AtEndOfStream
outputString=myFile.readline
response.write outputString & vbcrlf
Loop
' close everything
myFile.close
set myFile=nothing
set fso=nothing
' Flush everything in the buffer, thereby sending the file to the client.
response.flush

i know u will tell me to search it on web, i've tried a lil bit and found similar solutions
can anybody plz tell me is there anything wrong with the above script which i'm using, the header the method of writing the file back to client or anything
thnx in advance
raheel
Comment