HuyPV
Wednesday, April 29, 2009
'Support large file, big file
Sub Download(strFilePath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strFilePath) then
Response.Write "! >> File not found."
Else
Dim strFileName
Set objFIle = objFSO.GetFile(strFilePath)
strFileName = objFile.Name
If strFileName = "" then Exit Sub
Response.Clear
Response.Buffer = False
Response.AddHeader "Content-Disposition", "attachment; filename=""" & strFileName & """"
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"
Const adTypeBinary = 1
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
while Not objStream.EOS
Response.BinaryWrite objStream.Read(4096)
Wend
objStream.Close
End if
Set objStream = Nothing
Set objFSO = Nothing
Set objFile = Nothing
End Sub
Title:
Download file from server
Description:
'Support large file, big file Sub Download(strFilePath) Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ...
...
Rating:
4