Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small mp3 or wav download = easy. Large file = problem

Status
Not open for further replies.

KingElvis

Programmer
Jan 28, 2004
39
IL
Why is the user unable to download large .mp3 or .wav files with this code? It works perfectly well with small files.

(This is for you simonchristies... you helped me before)


<%
Set filesys = CreateObject("Scripting.FileSystemObject")

strWav = "/media/"&Request.Form("code1")&".mp3"
strFilename = server.MapPath(strWav)

if len(request.form("code1")) <7 Then
response.write "Please enter the correct number of digits."

else
If filesys.FileExists(strFilename) Then
strFilename = server.MapPath(strWav)

Response.Buffer = True
Response.Clear

Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFilename)
intFilelength = f.size

s.LoadFromFile(strFilename)

Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.Charset = "UTF-8"
Response.ContentType = "application/octet-stream"

Response.BinaryWrite s.Read
Response.Flush

s.Close
Set s = Nothing

Else
response.write "Sorry, your file is not yet prepared."
End If
End If
%>
 
i found some documentation on this online when i was messing with my binary stream issues, and you need to chop it up into smaller blocks to avoid a timeout/fubar...

here's a little documentation, not the exact one i was looking at but it might get you started ...

i'll keep looking for the other page
 
This isn't by some chance a class project, is it? Oddly enough another user posted almost exactly the same code for the same problem, so I was just curious: thread333-833090 by dermie

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
lol tarwn i think you're right, and the source looks nearly identical ( not to mention specifically MP3's )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top