任何人都可以帮助读取文件返回空。根据文档,它应该在错误时返回 false,为什么它会给出 null 作为响应。
http://php.net/manual/en/function.readfile.php
该文件存在于路径处,并且还设置了权限。页面的 http 响应为 200 OK。
$fileout = "/path/to/image/image.jpg";
if( file_exists( $fileout ) ) {
/* We already have a resized image
* So send the file to the browser */
switch(strtolower($ext))
{
case ".gif":
header ("Content-type: image/gif");
readfile($fileout);
break;
case ".jpg":
header ("Content-Type: image/jpeg");
readfile($fileout);
break;
case ".png":
header ("Content-type: image/png");
readfile($fileout);
break;
}
}
不同服务器(本地主机(上的相同代码工作正常,请建议我应该在哪里解决这个问题。
最后,我发现问题阅读文件功能在服务器(php.ini(中被禁用。php中有php设置.ini"disable_functions",我们可以在其中指定需要禁用的功能列表。在我的情况下,readfile列在此,当我删除它时,它似乎可以工作。
PHP有很多功能,如果使用不当,可以用来破解你的服务器。您可以使用disable_functions指令在 php 中设置函数列表.ini。此指令允许您出于安全原因禁用某些功能。它采用逗号分隔的函数名称列表。
有关更多详细信息,请参阅 http://php.net/manual/en/ini.core.php#ini.disable-functions