Jump to content

[SOLVED] header download dialog corrupting files


loony383

Recommended Posts

Ok so im using the following header code to send files

PHP Code:

header('Content-Description: File Transfer'); 
header('Content-Type: application/force-download'); 
header('Content-Disposition: attachment; filename='.basename($download_url)); 
header('Content-Transfer-Encoding: binary'); 
header('Expires: 0'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Pragma: public'); 
header('Content-Length: ' . filesize($download_url)); 
ob_clean(); 
flush(); 
readfile($download_url);  

But whenever a user downloads a file it's corrupted? My website allows users to upload files. I checked the files on the server and they're fine, not corrupted but when the user downloads the file it's corrupted?

 

Users can upload files with any extension to my website.

 

Help anyone?

There was this:

 

<br />

<b>Warning</b>:  filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for http://domain.net/uploads/1235318572/header.png in <b>/home/username/public_html/files/include/cookie.php</b> on line <b>96</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/username/public_html/files/include/cookie.php:96) in <b>/home/username/public_html/files/include/cookie.php</b> on line <b>96</b><br />

‰PNG

 

That fixed the problem but now I have another. Any documents that have a space in them get corrupted because it doesn't find it. As soon as there is a space in the file name it cuts it off (resulting in it not finding the file and instead just downloads an file full of the error when opened notepad). Anyone know an easy solution to this? (i don't really want to edit the unloader to rename the files with underscores)

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.