I'm using SonataMediaBundle with SonataAdminBundle and Symfony 2.3.
When I try to upload an image via the Sonata Admin interface:
- Click on "Add New" (
app_dev.php/admin/sonata/media/media/create
) - Click on "Image" (
app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.image&context=default
) - Browse the
image.jpg
file and click on "create" - 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:
- Click on "Add New" (
app_dev.php/admin/sonata/media/media/create
) - Click on "Image" (
app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.file&context=default
) - 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?