Jump to content

Strange header / file download output


techbinge

Recommended Posts

Hey everyone. I've got an issue, but I'm not 100% sure it's PHP.

 

I've created a simple php file download system that uses headers to obscure the URL of the file users will download. 90% of the time, you click the download link and you're prompted with an 'accept file download window'. The other 10% I get some crazy output like this:

 

HTTP/1.1 200 OK Date: Mon, 08 Mar 2010 03:43:33 GMT Server: Apache/2.0.54 X-Powered-By: PHP/5.2.6 Content-Transfer-Encoding: Binary Content-disposition: attachment; filename="WeaponAnim.zip" Content-length: 144 Vary: User-Agent Keep-Alive: timeout=5, max=99 Connection: Keep-Alive Content-Type: application/force-download PK�����I��;���������������JunkPile3dsMaxVideo.txtPK������I��;��������������������� �������JunkPile3dsMaxVideo.txtPK������E���5�����

 

Here is a snippet of the code I'm using to prompt the download:

				
$file = c_downloadDir . $aFileName[0]; // c_downloadDir = file directory constant & $aFileName[0] is from a query
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile("$file");

 

Any help at all would appreciated. Again, not sure if this is PHP, or some sort of apache / file / mime type issue.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/194469-strange-header-file-download-output/
Share on other sites

So, I've narrowed this down a bit. Seems when I request a file for download, all is fine. When I then try and request many files, in a short period of time (2-10 seconds) I start to see this output. I'm starting to think its a connection issue w/ Apache. Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.