PHP File Downloading Questions
Posted
by nsearle
on Stack Overflow
See other posts from Stack Overflow
or by nsearle
Published on 2010-04-12T17:33:25Z
Indexed on
2010/04/12
17:43 UTC
Read the original article
Hit count: 533
Hey All!
I am currently running into some problems with user's downloading a file stored on my server. I have code set up to auto download a file once the user hits the download button. It is working for all files, but when the size get's larger than 30 MB it is having issues. Is there a limit on user download? Also, I have supplied my example code and am wondering if there is a better practice than using the PHP function 'file_get_contents'.
Thank You all for the help!
$path = $_SERVER['DOCUMENT_ROOT'] . '../path/to/file/';
$filename = 'filename.zip';
$filesize = filesize($path . $filename);
@header("Content-type: application/zip");
@header("Content-Disposition: attachment; filename=$filename");
@header("Content-Length: $filesize")
echo file_get_contents($path . $filename);
© Stack Overflow or respective owner