Asp implements the file download function to download files directly without being opened by IE. Any files can be downloaded.
<Html>
<Head> <title> Download files without IE </title>
<Body>
<%
File = Request ("file ")
Call downloadFile (replace (file ,"",""),"/",""))
Function downloadFile (strFile)
'Make sure you are on the latest MDAC version for this to work
'-------------------------------------------------------------
If mid (strfile, 1, 5) = "http:" then
Response. write ("<a href =" & file & "> here" & file & "download </a> ")
'Response. redirect (file)
Exit function
End if
'Get full path of specified file
StrFilename = server. MapPath (strFile)
'Clear the buffer
Response. Buffer = True
Response. Clear
'Create stream
Set s = Server. CreateObject ("ADODB. Stream ")
S. Open
'Set as binary
S. Type = 1
'Load in the file
On error resume next
'Check the file exists
Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
If not fso. FileExists (strFilename) then
Response. Write ("Response. End
End if
'Get length of file
Set f = fso. GetFile (strFilename)
IntFilelength = f. size
S. LoadFromFile (strFilename)
If err then
Response. Write ("Response. End
End if
'Send the headers to the users browser
Response. AddHeader "Content-Disposition", "attachment; filename =" & f. name
Response. AddHeader "Content-Length", intFilelength
Response. CharSet = "UTF-8"
Response. ContentType = "application/octet-stream"
'Output the file to the browser
Response. BinaryWrite s. Read
Response. Flush
'Tidy up
S. Close
Set s = Nothing
End Function
%>
</Body>
</Html>
Indicate the original site reprinted, please indicate from: www.111cn.net