Session Problem with Header

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    Session Problem with Header

    i'm having problem with session_start() to force the browser to download file with this function:

    [PHP]
    session_start() ;
    function force_download( $file){
    if ((isset($file)) &&(file_exists( $file))) {
    header("Content-type: application/force-download");
    header('Content-Disposition: inline; filename="' . $file . '"');
    header("Content-Transfer-Encoding: Binary");
    header("Content-length: ".filesize($fil e));
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="' . $file . '"');
    readfile("$file ");
    } else {
    echo "No file selected";
    }
    }
    force_download( "EGYMIDICA 2008.pdf");
    [/PHP]
    when i delete the session_start() function the browser download the file with no problem how can i solve this with session?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    What is the problem?
    Are you getting any errors?

    As far as I can see, there is nothing wrong with that.
    The only thing I can think of is that the session_start() function is generating a warning, in which case adding a @ sign in front of it may fix the problem.

    Comment

    • smartic
      New Member
      • May 2007
      • 150

      #3
      i need code that foce the Browser to download my file then redirct the page or close it how can i do that?

      Comment

      Working...