Question about readfile

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • defogm
    New Member
    • Apr 2007
    • 1

    Question about readfile

    Hello everyone,

    I was woundering if PHP "readfile" method consume server bandwidth by the size of the file that is read.
    I am asking this because I am creating a download script for large file like this
    [PHP]
    ...
    header("Pragma: public");
    header("Expires : 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false) ;
    header("Content-Type: $type");
    header("Content-Disposition: attachment; filename=\"".ba sename($filenam e)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($fil ename));
    readfile("$file name");
    ....
    [/PHP]
    with the above code it seem that whenever some one choose to download file with that script, the bandwidth get consumed by the file size automaticly even if I tryied to cancel it after few kilobytes, it consume the whole file size

    am I wrong or not?
    and if there is other better way to do it please let me know

    what I need is to let the user download AVI files, this code
    [PHP]
    header('Locatio n: ' . $row['url']);
    [/PHP]
    works fine with Firefox, it show the save dialog and doesnt consume bandwidth
    but when trying it with IE, it automatically save it to the Temporary folder without showing the save dialog (open/save location dialog), and I dont want it to do this

    any help will be appreciated

    Thanks in advance,
Working...