Jump to content

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


Recommended Posts

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
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.