Symfony2 Sonata Media Bundle -- Error while uploading Image

1k views Asked by At

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 errorenter image description here

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

2

There are 2 answers

0
Daishy On

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

0
Jessica Morin On

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.