Download via PHP problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bert

    Download via PHP problem

    Hello,

    I'm using a script to handle downloads of files, it seems to work but
    I'm getting random server errors. I guess it has something to do with
    the filesize. The script will be needed to download files of 6 to 8 MB
    but I've only tested with files from 0.5 to 2.5 MB.

    I get the following error:
    The server closed the connection while reading the response. Contact
    your system administrator. (SERVER_RESPONS E_CLOSE)

    All help is greatly apreciated!

    B.

    <?php
    //...
    //Download part of the script:
    $zipfile="/path/to/the/zipfiles/".$_POST['orderid'].".zip";
    if (empty($zipfile ) || !file_exists($z ipfile)) {
    header("HTTP/1.1 404 Not Found");
    header("Status 404");
    Header("Locatio n:icouldnotfind thatfile");
    }
    else {
    $filesize=files ize($zipfile);
    $name= $_POST['orderid'].".zip";
    $mime='applicat ion/x-zip';
    //hack for bloody ie5.5
    if(preg_match("/MSIE 5.5/", $HTTP_USER_AGEN T))
    {header("Conten t-Disposition: filename=$name" );}
    //other browsers
    else {header("Conten t-Disposition: attachment; filename=$name" );}
    header("Content-Type: $mime");
    header("Content-Length: $filesize");
    header ("Content-Transfer-Encoding: binary");
    $fh = fopen($zipfile, "r");
    fpassthru($fh);
    }
    ?>
  • Fabian Wleklinski

    #2
    Re: Download via PHP problem

    Hi Bert,

    may be you have to increase the maximum execution time of
    your script, see [1].


    Greetings from Frankfurt / Germany,

    Fabian Wleklinski


    [1] http://www.php.net/function.set-time-limit


    Comment

    Working...