tyanque
04-15-2012, 04:13 PM
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));
header("Content-Type: application/x-pem-file");
header("Content-Transfer-Encoding: binary");
ob_clean();
flush();
readfile(basename($fullpath));
Any ideas as to why the file is a different size?
Thanks for any help.
$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));
header("Content-Type: application/x-pem-file");
header("Content-Transfer-Encoding: binary");
ob_clean();
flush();
readfile(basename($fullpath));
Any ideas as to why the file is a different size?
Thanks for any help.