2014-11-25 20:16
浏览 30


I have here a form that is uploading a photo. Initially I got an error because symfony couldn't create the direcotry so I created them manualy.

Now I get this error:

Unable to write in the "/home/crixi/projects/symfony/src/Acme/TestBundle/Entity/../../../../web/uploads/picture" directory 

I'm using ubuntu.

Is there any settings that I should to to assign symfony the righs to write in that folder?

图片转代码服务由CSDN问答提供 功能建议

我这里有一张上传照片的表格。 最初我收到错误,因为symfony无法创建目录,所以我手动创建它们。


  <  / pre> 



  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxin8383
    douxin8383 2014-11-25 21:00

    If you are using Ubuntu, then your web user will be www-data, not apache. So that's why it wouldn't work when you changed the apache permissions. You can do this properly by doing the following:

    1. sudo chgrp -R www-data /home/crixi/projects/symfony/web/uploads
    2. sudo chmod -R g+rwx /home/crixi/projects/symfony/web/uploads

    This will allow the web user (www-data) the proper permissions to write to your upload dir and subdirs. This is better than giving everyone write permissions because it's always good to do things right in the dev env so you don't have issues when going to prod.

    OR, as @Wrikken suggests, just use chown like so:

    sudo chown -R www-data /home/crixi/projects/symfony/web/uploads

    It just depends how you want to manage your permissions.

    点赞 评论