Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 - Where should I put files uploaded by users? [closed]

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?

like image 794
Farid Movsumov Avatar asked Oct 18 '13 19:10

Farid Movsumov


1 Answers

My personal solution is to put them in the /app/data/uploads directory, and then either:

  1. Create symlinks to the upload directory, or
  2. 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.

like image 172
Mike Avatar answered Sep 19 '22 21:09

Mike