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?

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.