Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
Welcome, Guest
Username Password: Remember me

Downloading (pushing) large files
(1 viewing) (1) Guest
ASP.NET PROGRAMS, ASP.NET DESIGN, ASP.NET CODE, ASP.NET TOOLS

ASP.NET combines Active Server Pages with the .NET Framework. This technology allows you to create dynamic web applications. ASP.NET pages work in all browsers. Best of all, ASP.NET lets you build web pages using less code than you need with classic ASP. If you’re using ASP.NET to build some applications for your website, you owe it to yourself to check out the articles in this section.
  • Page:
  • 1

TOPIC: Downloading (pushing) large files

Downloading (pushing) large files 08 Dec 2009 07:25 #43

 
 
sub SendFileToResponse(FilePath, FileName)
dim clChunkSize, oStream, length
 
clChunkSize = 1048576
Response.Buffer = false
 
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; Filename=" + FileName
 
set oStream = Server.CreateObject("ADODB.Stream")
oStream.Type = 1
oStream.Open()
oStream.LoadFromFile(FilePath)
 
Response.AddHeader "Content-Length", oStream.Size
 
length = int (oStream.Size / clChunkSize)
if(length > 0) then
for i = 1 to length
Response.BinaryWrite oStream.Read(clChunkSize)
next
end if
 
if ((oStream.Size mod clChunkSize) >0) then
Response.BinaryWrite oStream.Read(oStream.Size mod clChunkSize)
end if
oStream.Close()
end sub
 
  • mnjon
  • OFFLINE
  • CE Staff
  • Posts: 78
  • Karma: 40
CodersEngine
  • Page:
  • 1
Time to create page: 0.26 seconds