| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
HI,
i'm making a download file so it forces to download but there is a problem: when i download something below 4MB the script does his work but when i download something above 4MB i can save the file, and than i ge the file though but it's 0 bytes. can anyone help me plz here's the script Code:
<%
call downloadFile(replace(replace(Request("file"),"\",""),"/",""))
function downloadFile(strFile)
strFilename = server.MapPath(strFile)
Response.Buffer = True
Response.Clear
Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1
on error resume next
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")
Response.End
end if
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.Charset = "UTF-8"
Response.ContentType = "video/avi"<===== the file that i want to download above 4MB is avi (mp3 doesn't work either)
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s = Nothing
end function
%>
|
|
#2
|
||||
|
||||
|
Comment this line out so that you can see what the error is:
Code:
on error resume next
__________________
selwonk If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more! Last edited by selwonk : September 30th, 2004 at 06:17 AM. |
|
#3
|
|||
|
|||
|
when i do this, i get this error
HTTP-error 500 what can i do about it??? |
|
#4
|
||||
|
||||
|
You need to turn off friendly error messages on your server:
http://www.google.com/search?hl=en&...G=Google+Search |
|
#5
|
|||
|
|||
|
ok, i turned it of.
i now get the download dialog, but when i say save as i don't get the dialog where i can save the file on my hdd. and the file name what you see in the first dialog isn't what it suppose to be, i also get a wrong icon in the dialog of the program that i play the files with (win XP SP2) so the download doesn't start but i ge the first dialog now id there a solution??? tnx |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > help force filedownload |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|