468,760 Members | 1,899 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,760 developers. It's quick & easy.

Question about readfile

1
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=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
....
[/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('Location: ' . $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,
Apr 7 '07 #1
0 1187

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by dario | last post: by
1 post views Thread by Jørn Dahl-Stamnes | last post: by
3 posts views Thread by Paul F. Johnson | last post: by
4 posts views Thread by Eric Renken | last post: by
1 post views Thread by mkarja | last post: by
15 posts views Thread by Ketchup | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.