title: move_uploaded_file() expects parameter 2 to be valid path, object given
body: <p>I'm using Symfony 2.3 to save a file uploaded by a form POST.</p>
  
  <p>This is the code I use in the controller:</p>
  
  <pre><code>$fileDir = '/home2/divine/Symfony/src/App/Bundle/Resources/public/files';
  
  $form['my_file']-&gt;getData()-&gt;move($fileDir, 'book.pdf');
  </code></pre>
  
  <p>Under water, Symfony executes this code to move the file:</p>
  
  <pre><code>move_uploaded_file("/tmp/phpBM9kw8", "/home2/divine/Symfony/src/App/Bundle/Resources/public/files/book.pdf");
  </code></pre>
  
  <p>The public directory has 777 permissions.</p>
  
  <p>This is the error I get:</p>
  
  <pre><code>"Could not move the file "/tmp/phpBM9kw8" to "/home2/divine/Symfony/src/App/Bundle/Resources/public/files/book.pdf" 
  
  (move_uploaded_file() expects parameter 2 to be valid path, object given)" 
  </code></pre>
  
  <p>I'm using PHP 5.3.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>This is the code snipped that executes the move_uploaded_file():</p>
  
  <pre><code>// Class: Symfony\Component\HttpFoundation\File\UploadedFile
  
  $target = $this-&gt;getTargetFile($directory, $name);
  
  if (!@move_uploaded_file($this-&gt;getPathname(), $target)) {
  
  // etc...
  </code></pre>
  
  <p>The $target" variable is created here:</p>
  
  <pre><code>protected function getTargetFile($directory, $name = null) {
  
  // Some error handling here...
  
      $target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this-&gt;getBasename() : $this-&gt;getName($name));
  
      return new File($target, false);
  }
  </code></pre>
  
  <p>The $target variable is therefor a File class. It does have a __toString() method, inherited from SplFileInfo:</p>
  
  <pre><code>/**
   * Returns the path to the file as a string
   * @link http://php.net/manual/en/splfileinfo.tostring.php
   * @return string the path to the file.
   * @since 5.1.2
   */
  public function __toString () {}
  </code></pre>
  
  <p>But somehow that __toString method is not working.</p>