任何人都可以帮助readfile返回null。根据文档,它应该在出错时返回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;
}
}
不同服务器(localhost)上的相同代码工作正常,请建议我为了解决此问题而打了哪个shuld。
答案 0 :(得分:0)
最后我发现在服务器(php.ini)中禁用了readfile函数问题。在php.ini“disable_functions”中有php设置,我们可以在其中指定需要禁用的功能列表。在我的情况下,readfile在此列出,当我删除它似乎工作。
PHP有很多功能,如果使用不当可以用来破解你的服务器。您可以使用disable_functions指令在php.ini中设置函数列表。该指令允许您出于安全原因禁用某些功能。它采用以逗号分隔的函数名列表。
有关详细信息,请参阅http://php.net/manual/en/ini.core.php#ini.disable-functions