Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-01-2013, 06:00 PM #1
- Join Date
- Jul 2011
- Thanked 0 Times in 0 Posts
Error during Safari readfile() download
I'm writing a secure file download system and it works fantastically except for safari users.
I have had several points of feedback saying that when they download a zip file via safari it locates the file and shows that it should start downloading but doesnt, resulting in a 0-filesize zip.
I'm using the code below for the actual download, do you have any idea what could be causing the issue?
The $filename is set earlier in the script but just for arguments sake, lets assume it's, myfiles.zip
$path = "http://www.root.com/".$filename;
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($path)) );
header('Content-Disposition: attachment; filename="'.basename($path).'"');
readfile($path); // outputs the content of the file
03-02-2013, 12:02 PM #2
- Join Date
- Feb 2011
- Your Monitor
- Thanked 503 Times in 490 Posts
Also look at the filename in the content-disposition header - you're giving the file a url as a name. Finally you're trying to output a file directly from a url.
All of those $path variables should relate to the file on file system.My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!