Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: HTTP Headers download problem
04-15-2012, 04:13 PM #1
- Join Date
- Mar 2007
- Thanked 2 Times in 2 Posts
HTTP Headers download problem
Hey, I've wrote a script which creates a .pem file, once the form has been submitted I'm trying to send the file using headers, but the file it outputs is a different size to the one that the script creates. The original file works fine, but downloaded one won't open. Here is the code I'm using to download the file.
$filename = urlencode($filename);
$fullpath = realpath("keys/$filename");
$size = filesize("keys/$filename");
header('Cache Control: public');
header("Content-Description: File Transfer");
header("Content-Length:" . $size);
header("Content-Disposition: attachment; filename=" . basename($fullpath));
Thanks for any help.
Last edited by tyanque; 04-15-2012 at 04:51 PM.
04-15-2012, 08:15 PM #2
- Join Date
- Feb 2011
- Your Monitor
- Thanked 528 Times in 515 Posts
From the looks of your code you're using output buffering. Why then are you using ob_clean to clean the buffer - including those headers you've just created?
See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/
Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!