title: Symfony2 dynamic upload directory
body: <p>I have followed the cookbook for <a href="http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html" rel="nofollow">file uploads</a> (using the id as filename) and it works very good. I want to use this entity on my whole website. For example, admins can upload images for blog posts, users can upload certain file types in the comments etc..
  Currently, all the files are saved in web/uploads/documents. But I want to save files in folders based on which form they are uploaded in. For example, images for blog posts are stored in web/uploads/blog/, user files are stored in  web/uploads/<em>MIMETYPE</em>/ etc..
  In the entity, the path is set in the <code>getUploadDir</code> function:</p>
  
  <pre><code>public function getUploadDir()
  {
      return 'uploads/documents';
  }
  </code></pre>
  
  <p>I thought of using <a href="http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html" rel="nofollow">form events</a>, but I have no idea how to do that properly.</p>
  
  <p>So, how can I achieve that if it is even possible without using different entities?</p>