Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Uploaded Files in Symfony2 are of type <a href="http://api.symfony.com/master/Symfony/Component/HttpFoundation/File/UploadedFile.html" rel="nofollow">Symfony/Component/HttpFoundation/File/UploadedFile</a>.</p> <p>You can get the original client name ( php will rename files when putting them into php_upload_tmp_dir ) with:</p> <pre><code>$file-&gt;getClientOriginalName(); </code></pre> <p>... <a href="http://api.symfony.com/master/Symfony/Component/HttpFoundation/File/UploadedFile.html#method_move" rel="nofollow">move</a> the file to a new location with:</p> <pre><code>$file-&gt;move('path/to/your_file', 'new_name.jpg'); </code></pre> <hr> <p>You can not use the assert File Constraint for an array.</p> <pre><code>* @Assert\File(maxSize="6000000") */ protected $files = array(); </code></pre> <p>Therefore you need the <a href="http://symfony.com/doc/master/reference/constraints/All.html" rel="nofollow">All</a> constraint.</p> <p>Furthermore you can't just call the move method on an array or collection... you will have to loop over the collection/array.</p> <pre><code>$this-&gt;files-&gt;move('..') // this is never going to work... </code></pre> <hr> <p>Use an array collection and create a property for your uploaded files if thats what you want.</p> <pre><code>protected $files; protected $uploadedFiles; public function __construct() { $this-&gt;files = new ArrayCollection; $this-&gt;uploadedFiles = new Array(); } </code></pre> <p>If you want to transform your Doctrine Collection of UploadedFile entities into an Array do the following:</p> <pre><code>$collection = $entity-&gt;getFiles(); $array = $collection-&gt;toArray(); </code></pre> <p><em>But whatever you're trying to do ... better use OOP instead of arrays like you're attempting here.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload