【发布时间】:2014-10-30 07:28:03
【问题描述】:
我最近迁移了 linux 服务器。
我目前在尝试使用 Imagick 从表单上传图片时遇到此错误。
Warning: fopen(/home/user/public/website.com/public/images/users/current/thumb/username.jpg): failed to open stream: Permission denied in /home/user/public/website.com/public/inc/functions/functions.php on line 864
运行的代码驻留在函数中:
try{
$im = new Imagick($image['tmp_name']);
if($im_w != 'O' && $im_h != 'O'){
$im->cropThumbnailImage($im_w,$im_h);
}
$fp = fopen($path, 'w'); //the line that is causing the error to occur. line 864.
$im->writeImageFile($fp);
return 1;
}
catch(Exception $e)
{
echo $e->getMessage();
}
我查看了各种 PHP/Linux 权限修复程序,/images/ 目录和子目录当前具有权限:755
谁能帮我解决一下。如果您需要了解其他信息,请发表评论。
提前致谢。
【问题讨论】:
-
您是否尝试过使用 777,可能是 Web 文件的所有者与尝试写入该目录的所有者不同。我相信 755 只允许文件的所有者写入/编辑,而 777 允许任何用户。
-
777有什么缺点吗?
-
不是系统管理员,但据我所知...如果您使用共享主机或允许匿名 FTP,那么 777 不是最好的主意。如果您在专用服务器上,那么您应该没问题。
-
酷,我在专用服务器上。 :) 谢谢
标签: php linux permissions fopen imagick