php - warning feof() expects parameter 1 to be resource -
my error logs getting out of control 2 below errors
warning feof() expects parameter 1 resource
and
warning fread() expects parameter 1 resource
the bit of code responsible is
<?php $file = '../upload/files/' . $filex; header("content-disposition: attachment; filename=" . urlencode($file)); header("content-type: application/force-download"); header("content-type: application/octet-stream"); header("content-type: application/download"); header("content-description: file transfer"); header("content-length: " . filesize($file)); flush(); // doesn't matter. $fp = fopen($file, "r"); while (!feof($fp)) { echo fread($fp, 65536); flush(); // essential large downloads } fclose($fp); ?>
i used code header downloads freaking out right - before asks have tried, tried google still don't understand error message.
fopen fails , returns false. false not resource, warning.
you'd better test $fp before injecting resource-like argument:
if(($fp = fopen($file, "r"))) { [...] }
Comments
Post a Comment