<%@ Language=VBScript %> <% Response.Expires=0 Response.Buffer=0 Const CHUNK = 2048 strFilePath = Server.MapPath(Request.QueryString("file")) Set fso = Server.CreateObject("Scripting.FileSystemObject") ' Controllo se esiste il file (qua si possono mettere altri controlli) if fso.FileExists(strFilePath) then set objFile = fso.GetFile(strFilePath) Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name Response.AddHeader "Content-Length", objFile.Size Response.ContentType = "application/octet-stream" Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open objStream.Type = 1 ' adTypeBinary objStream.LoadFromFile strFilePath lSize = objStream.Size lBlocks = 1 For lBlocks = lBlocks To lSize \ CHUNK If Response.IsClientConnected = False Then Exit For Response.BinaryWrite objStream.Read(CHUNK) Next lSize = lSize Mod CHUNK If lSize > 0 And Response.IsClientConnected = True Then Response.BinaryWrite objStream.Read(lSize) End If objStream.Close Set objStream = Nothing else %><% end if%>