Hi all, A page in my website forces a file download when users click on a corresponding link. Here is the code that sets the headers:
@$filesize = filesize($fileName);
if($filesize)
{
@Header("Content-Length: ".$filesize);
@Header("Content-Disposition: attachment; filename=".$file);
@readfile($fileName);
}
This works great BUT i get this odd error that occurs EVERY OTHER time I click on one of the links. So if I click on link 1 I get the file download, but then when i click on link 2 I get an error message. If i then click on link 3 I get a file download and if I click on link 1 i get an error message again...
Here is what the error message looks like:
HTTP/1.1 200 OK Date: Thu, 10 Jul 2003 19:50:55 GMT Server: Apache/1.3.23 (Win32) Content-Disposition: attachment; filename=335.pdf X-Powered-By: PHP/4.1.1 Content-Length: 308596 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Content-Type: text/html %PDF-1.4 %âãÏÓ 1 0 obj << /Type /Page /Parent 59 0 R /Resources 2 0 R /Contents 3 0 R /MediaBox [ 0 0 1224 792 ] /CropBox [ 0 0 1224 792 ] /Rotate 0 >>
From my guess the headers need to be reset, am I on the right track here? Anyone have an idea of what I should look into doing next? Thanks