Re: File Download Problems
| From: | Marek Kilimajer | Date: | Wed, 15 Sep 2004 21:35:06 +0000 |
| Subject: | Re: File Download Problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196791@lists.php.net to get a copy of this message | ||
PHP Junkie wrote:
Ave, I've been having a very nagging and frustrating problem for a while and I hope someone can help me out with this. I created a simple File Manager application, a lot of you already know about it as you helped me with coding at different stages. The problem is this: The Download. When you download a file, it's giving problems sometimes. What is happening is, a 1 KB file downloads instead of the actual file. And thus the file downloaded is no good. The file uploaded is absolutely perfect. Since I have the web server which contains this website, I'm easily able to check all these things. When a user uploads a file, it's uploaded absolutely perfect. It's not a 1 KB file.. The whole file is uploaded and it's not corrupt. But when a user downloads the file... Most of the time a 1 KB file is downloaded.. And its' corrupt of course. The more frustrating part is, it happens sometimes.. Not everytime. It is happening 90% of the time.. But sometimes it is able to download the actual file. If you try the same file from different locations, 15 times... 1 out of 15 times the file will download fine. I've been doing all sorts of testing to narrow down the problem but I don't know the problem. This is my download script : <?php $file = "$P/$F"; header("Content-Description: File Transfer"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($file)); @readfile($file); ?> Which is called using this link on the main page: <a href=\"imsafm_user_dl.php?ID=$myrow[ID]&P=imsafm/$user&F=$myrow[filename]\"> <img src=b_newtbl.png border=0></a>What does the 1 KB file contain? Is it the beginning of the wanted file? Remove @ while debuging. Add header('Content-Lenght: ' . filesize($file)); Check server logs. HTH