Jump to content
Larry Ullman's Book Forums

Readfile Vs Fopen


Recommended Posts

I would like to force download a .zip file to a user's computer using PHP. I was planning on using the readfile() function (along with the headers required), but then I stumbled across another method using fopen(), feof(), and fread() that appears to download files also...

 

//necessary headers...

if (($f = fopen($fullPath, 'rb')) === false) exit;

while (!feof($f)) {

echo fread($f, (1*(1024*1024)));

flush();

@ob_flush();

}

fclose($f);

 

My question: To download a .zip file (that is approximately 85MB) to a user's computer using php, should I use readfile() or fopen()? Can you provide PHP code for me to use with the recommended function?

 

Thank you very much.

Link to comment
Share on other sites

 Share

×
×
  • Create New...