Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
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:
- Create symlinks to the upload directory, or
- Serve the uploads via a controller
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
.