...

View Full Version : code for downloading AVI file



parthi
02-22-2007, 08:31 AM
Hai i am new to server side scripting, i am creating a web page in that there is an link called download if the user clicks at it it has to download the avi file stored in the database.
it has to ask the user the specific location for saving.

whats the code for downloading the file and save in the directory the user specifies.

if you know please guide me

angst
02-22-2007, 03:39 PM
i assume that your talking about a way to force the file to download instead of opening?

try:



Function DownloadFile(file)

Dim strAbsFile
Dim strFileExtension
Dim objFSO
Dim objFile
Dim objStream

strAbsFile = Server.MapPath(file)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strAbsFile) Then

Set objFile = objFSO.GetFile(strAbsFile)
Response.Clear

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
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strAbsFile)
'-- send the stream in the response
Response.BinaryWrite(objStream.Read)
objStream.Close
Set objStream = Nothing
Set objFile = Nothing

Else 'objFSO.FileExists(strAbsFile)
Response.Clear
Response.Write("There is no such file.")
End If

Set objFSO = Nothing
End Function

parthi
02-23-2007, 11:37 AM
thank you for the code,it will be very useful to me.

degsy
02-28-2007, 02:52 PM
Here is an ASP Download Manager
http://forums.aspfree.com/code-bank-54/download-manager-downloading-files-from-secure-location-classic-asp-65239.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum