我的错误日志因以下两个错误而失控
warning feof() expects parameter 1 to be resource
和
warning fread() expects parameter 1 to be resource
负责的代码是
<?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(); // this doesn't really matter.
$fp = fopen($file, "r");
while (!feof($fp)) {
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
?>
我将此代码用于标题下载,但现在它吓坏了 - 在有人问我尝试过什么之前,我尝试了谷歌,但仍然不完全理解错误消息。