How to Download Large files using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dinakar
Forum Newbie
Posts: 2
Joined: Tue Feb 10, 2009 4:26 am

How to Download Large files using php

Post by dinakar »

Please help me to to know how to download a large file ( size 500mb) using php
i had used the following code which dosent work for me for downloading large files

$fd = fopen ($file, "r");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
fclose ($fd);
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: How to Download Large files using php

Post by Eran »

Naturally for large files you will time out before completing the download. The default time limit for PHP is 60 seconds. You can change the time limit using set_time_limit() (a zero value will disable it completely). You can only do that though if your server is not running in safe mode
Post Reply