6

I'm using SonataMediaBundle with SonataAdminBundle and Symfony 2.3.

When I try to upload an image via the Sonata Admin interface:

  1. Click on "Add New" (app_dev.php/admin/sonata/media/media/create)
  2. Click on "Image" (app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.image&context=default)
  3. Browse the image.jpg file and click on "create"
  4. This leads me to the edit page where I can see: Item "image.jpg" has been successfully created.

And indeed:

  • In the folder web\uploads\media\default\0001\01 I have my image file and the 3 thumbs
  • In the media__media DB table I have the corresponding line
  • When I browse web/uploads/media/default/0001/01/ with Firefox I can see my image
  • The corresponding line appears in the media list (in admin panel)

But:

  • The image is not displayed in the media list (there is a square instead of the thumb) nor in the image edit page (app_dev.php/admin/sonata/media/media/3/edit?provider=sonata.media.provider.image&context=default)

For the files, it's even worse:

  1. Click on "Add New" (app_dev.php/admin/sonata/media/media/create)
  2. Click on "Image" (app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.file&context=default)
  3. Browse the document.zip file and click on "create"

This generates the error 500: The file "" does not exist. And no new line is created in the DB.


Piece of solution

For the image problem, I noticed that the path where sonata admin was looking was not the good one: I it looking in: http://myserver/uploads/media/default/0001/01/c35f187f1b405f4bfba8b962d83e5bbdccff54f9.jpeg

Instead of http://myserver/myproject/web/uploads/media/default/0001/01/c35f187f1b405f4bfba8b962d83e5bbdccff54f9.jpeg

Apparently, this is due to this part of the config.yml (as defined in SonataMedia documentation):

sonata_media
    cdn:
        server:
            path: /uploads/media

That I replaced by:

sonata_media
    cdn:
        server:
            path: /myproject/web/uploads/media

And it works. But I don't think it's a good idea to hardcode this there. And I guess that there is a good reason why it it written this way in the Sonata Doc, no?

Is my modification correct? If not, how should I do?

In any case, it doesn't solve my file uploading problem! Any idea on this point?

2
  • 1
    I have the exact same problem. Have you found a solution yet?
    – Jan Šimek
    Dec 20, 2014 at 11:00
  • is the target directory got sufficent writable permissions for apache or nginx ?
    – ibasaw
    Jan 11, 2016 at 15:50

2 Answers 2

3

The file "" does not exist

As explained here, this is caused by insufficient limit for allowed upload file size in php.ini (increase upload_max_filesize and post_max_size).

Then you will probably stumble on another error saying that the zip file type is not allowed, so add this into your config.yml:

sonata_media:   
    providers:
        file:
            allowed_extensions: ['zip']
0
sonata_media
    cdn:
        server:
            path: /myproject/web/uploads/media

This is the working option. I don't think there is a problem to hard code this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.