简体   繁体   中英

Symfony2 Sonata Media Bundle — Error while uploading Image

I updated the composer.json. Everything was working fine except the media section of sonata media bundle. When i upload any image i got a error 在此输入图像描述

I haven't changed any configuration. I am not able to figure the problem. I also give full permission to uploads folder recursively.

I also getting some exception

 CRITICAL - Uncaught PHP Exception RuntimeException: "Could not write the "default/0001/01/46475120624f7b54c71ddf500322b395e3d598da.jpeg" key content." at /vendor/knplabs/gaufrette/src/Gaufrette/Filesystem.php line 111  

Anyone faced this type of error

You just need to change the permissions of web folder in your appliaction. eg chmod 777 web/* -Rf

I got the same issue on my Linux server.

My problem was that my Apache user wasn't the owner of my upload folder (Folder set in config/sonata_media.yml). For reference, mine is : %kernel.root_dir%/../web/uploads/media

What I did was:

1) Logging as sudoer in my Linux server 2) Going to the parent folder of my uploads folder. So /web folder 3) Changing the user of the uploads folder with: chown -R apache-user uploads 4) Changing the group of the uploads folder with: chgrp -R apache-group uploads 5) Typing ls -ltr to confirm that my apache user is now the owner

Locally, on Windows, I just set the folder to have write rights.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM