I'm using SonataMediaBundle with SonataAdminBundle and Symfony 2.3.
When I try to upload an image via the Sonata Admin interface:
app_dev.php/admin/sonata/media/media/create
)app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.image&context=default
)image.jpg
file and click on "create"Item "image.jpg" has been successfully created.
And indeed:
web\uploads\media\default\0001\01
I have my image file and the 3 thumbsmedia__media
DB table I have the corresponding lineweb/uploads/media/default/0001/01/
with Firefox I can see my imageBut:
app_dev.php/admin/sonata/media/media/3/edit?provider=sonata.media.provider.image&context=default
)For the files, it's even worse:
app_dev.php/admin/sonata/media/media/create
)app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.file&context=default
)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?
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']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With