【发布时间】:2018-12-21 16:27:10
【问题描述】:
我创建了 laravel 项目,可以在我的本地 Windows 电脑上正常工作。一旦我上传到 Centos7 服务器(通过 SSH),上传图像时出现问题,无法写入该目录。 (项目文件结构https://ibb.co/5MLcFtd)
Unable to write in the "upload/register/picture."
已经试过了:
chown apache:apache -R /var/www/html/srp/upload
chmod -R 755 /var/www/html/srp/upload
和
chown apache:apache -R /var/www/html/srp/upload/register/picture
chmod -R 755 /var/www/html/srp/upload/register/picture
这是上传代码。
if(Request::hasFile('picture')){
$file = Request::file('picture');
if( in_array($file->getClientOriginalExtension(), $extension_picture) ){
$new_name = str_random(10).".".$file->getClientOriginalExtension();
$file->move('upload/register/picture' , $new_name);
$new->picture = "upload/register/picture/".$new_name;
}
}
两者都不起作用。非常感谢所有答案。
【问题讨论】:
-
apache 用户是否也在运行 web 服务器?
-
嗨 Autista_z,它是 CentOs7,应该是 apache,就像这张图片一样 ibb.co/t4zXYrx
-
Unable to write in the "upload/register/picture."不是真正的错误消息。你看到的错误是什么,究竟是什么?是来自storage/logs/laravel.log,还是Apache日志? -
另外,请向我们展示
upload/和子目录的权限。
标签: laravel