I am new with Symfony and I put images uploded by users under /web/bundles/mybundle/images/
directory. But I feel it's not good practice. Because when I run command below to create symlinks to other files under src
directory. All images uploaded by users were removed.
php app/console assets:install ./web --symlink
Where should I put images uploaded by users?
My personal solution is to put them in the /app/data/uploads
directory, and then either:
Option 1 is probably your best bet for images and assets, as you want them served as quickly as possible. However, for other content (PDFs, Docs, etc), option 2 might be your better bet, as you have more control over how you want the content served.
I prefer to keep my /web
directory as clean as possible, and keep file uploads outside of public scope (allowing me to change my method of serving the files without needing to move them -- IE Moving from Option 1 above to Option 2), but if you want to store them in the web folder, you can follow the Symfony Cookbook and store them in something like /web/uploads
.
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