Laravel无法在CentOs7的目录中写入

时间:2018-12-21 06:50:35

标签: laravel

我创建了laravel项目,该项目在我的本地Windows pc上运行良好。一旦我通过SSH上传到Centos7服务器,就无法上传图像,无法写入该目录。 (项目文件结构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;
        }
    }

两者都不起作用。非常感谢所有答案。

1 个答案:

答案 0 :(得分:0)

我认为您使用的ssh用户没有写权限。在这种情况下,您应该通过root用户(与ssh root@your_server连接)上载,或授予写入与之连接的用户的权限。 (为此,您仍然需要root用户访问权限)