dptr1988 Posted June 13, 2006 Share Posted June 13, 2006 I made a php script for sending a file but it only sends the first 24,576 bytes. This is the code:[code]header('Content-type: application/binary');header('Content-Disposition: attachment; filename='.$_GET['fname']);readfile($filedir.$_GET['fname']);[/code]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 Link to comment https://forums.phpfreaks.com/topic/11901-sending-with-type-applicationbinary-only-downloads-24576-bytes/ Share on other sites More sharing options...
poirot Posted June 13, 2006 Share Posted June 13, 2006 Try to send a Content-Length header:[code]$size = filesize($filedir . $_GET['fname']);header('Content-Length: ' . $size);[/code] Link to comment https://forums.phpfreaks.com/topic/11901-sending-with-type-applicationbinary-only-downloads-24576-bytes/#findComment-45152 Share on other sites More sharing options...
dptr1988 Posted June 13, 2006 Author Share Posted June 13, 2006 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:[code]header('Content-Length: '.filesize($filedir.$_GET['fname']));[/code]Thanks Link to comment https://forums.phpfreaks.com/topic/11901-sending-with-type-applicationbinary-only-downloads-24576-bytes/#findComment-45167 Share on other sites More sharing options...
dptr1988 Posted June 13, 2006 Author Share Posted June 13, 2006 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! Link to comment https://forums.phpfreaks.com/topic/11901-sending-with-type-applicationbinary-only-downloads-24576-bytes/#findComment-45275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.