Hello,
I seem to be having a problem with my script. I can't seem to get it to download a file using fopen. readfile works great, but with files that exceed 4MB size readfile will not work. So to fix this I use fopen for files over 4MB. When it tries to download the file, I get an error saying that the source file cannot be read. I double checked the file its attempting to download and it has permissions 0644, and when transferred via FTP it works fine. Can anyone shed some light on why this is broken? (This just recently started happening, for a while the script worked great).
$filename = 'downloads/file.zip';
if (filesize($filename) > 4194304)
{
$fp = fopen($filename, 'rb');
while (!feof($fp))
{
echo fread($fp, 8192);
flush();
}
fclose($fp);
}
else
{
readfile($filename);
}
Any help is appreciated. Thank you.