Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    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.
    PHP Code:
    $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.
    Last edited by tyanque; 04-15-2012 at 05:51 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 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?
    I can't really think of anything to write here now...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •