Hope4You Posted June 27, 2011 Share Posted June 27, 2011 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 More sharing options...
Larry Posted June 29, 2011 Share Posted June 29, 2011 Perhaps there are benefits to using fopen() et al. that I'm unaware of, but my inclination would be to just use readfile(). Link to comment Share on other sites More sharing options...
Recommended Posts