Jump to content


Photo

Sending with type application/binary only downloads 24,576 bytes


  • Please log in to reply
3 replies to this topic

#1 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 13 June 2006 - 06:08 PM

I made a php script for sending a file but it only sends the first 24,576 bytes. This is the code:

header('Content-type:  application/binary');
header('Content-Disposition: attachment; filename='.$_GET['fname']);
readfile($filedir.$_GET['fname']);

Then run the script with "send_file.php?fname=filename.jpg" and everything is normal except that the file is limited to 24,576 bytes. Do I need to change a setting in my php.ini?
Thanks

Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 13 June 2006 - 06:23 PM

Try to send a Content-Length header:

$size = filesize($filedir . $_GET['fname']);
header('Content-Length: ' . $size);

~ D Kuang

#3 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 13 June 2006 - 06:44 PM

I sent the Content-Length header and now the files are the right size. But now there is garbage in the files. I made a file full of zeros and tried downloading it and there are a whole lot of other numbers besides zero. And it's not readable text or anything that looks good. It just looks like random numbers. Am I useing the wrong content type for a binary file?

BTW here's the way I'm sending the Content-Length header:
header('Content-Length: '.filesize($filedir.$_GET['fname']));

Thanks


Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#4 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 13 June 2006 - 10:49 PM

readfile() was sending NTFS stuff. So I replaced it with fopen() fread() print() and now it works. Thanks poirot for helping me with my headers!


Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users