Forum Moderators: open
I've tried the code below in various fashions, from changing the ContentType to octet-stream, to using text (ascii) instead of binary (which in case you're wondering downloads the script file, not the attachment file, then crashes IE). In the end, the files will all be protected in a non-web accessible directory with the filename being passed into the script via the URL or a post/get (not sure which yet). The example below that I've been testing with just calls upon a file located in the same directory as the script.
<%
Response.ContentType = "application/zip"
Response.AddHeader "Content-disposition","attachment;filename=myfile.exe"
Dim strFilePath
strFilePath = Server.MapPath("myfile.exe")
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1 '1=binary 2=text
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
%>
I need some help. Any legacy ASP guru's out there?
<%
Dim strFileName
strFileName = "t.zip"Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-disposition","attachment;filename=" & strFileName
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1 '1=binary 2=text
objStream.LoadFromFile Server.MapPath(strFileName)
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
%>
I am pulling hair out...