title: Upload photo without form (API)
body: <p>I'm making an app mobile and I need to upload a photo from my camera via my API. But when doctrine try to <code>INSERT INTO</code>, he isn't happy because my <code>name</code> field is <code>null</code>. So the name generate by my entity is missing.</p>
  
  <p>I don't understand where the code block. My web app uses already the same entity photo and everything works fine.</p>
  
  <p>My Api controller:</p>
  
  <pre><code>&lt;?php
  /**
   * @throws AccessDeniedException
   * @return array
   * @FOSRest\View()
   */
  public function apiUploadAction()
  {
      $photo = new Photo;
      $photo-&gt;setUser($this-&gt;getUser());
      $photo-&gt;setFile = new UploadedFile(
          $_FILES["file"]["tmp_name"], 
          $_FILES["file"]["name"],
          $_FILES["file"]["type"],
          $_FILES["file"]["size"],
          $_FILES["file"]["error"],
          $test = false
      );
  
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $em-&gt;persist($photo);
      $em-&gt;flush();
  
      $apiResponse = array(
          "code"      =&gt; true,
          "style"     =&gt; "success",
          /*********** SCREENSHOT COMES FROM HERE ***********/
          "message"   =&gt; $_FILES["file"]["tmp_name"]."    ".$_FILES["file"]["name"]."    ".$_FILES["file"]["type"]."    ".$_FILES["file"]["size"]."    ".$_FILES["file"]["error"],
      );
  
      $view = View::create();
      $view-&gt;setFormat('json');
      $view-&gt;setData($apiResponse);
      return $this-&gt;get('fos_rest.view_handler')-&gt;handle($view);
  }
  </code></pre>
  
  <p>The $apiResponse.message (screenshot):</p>
  
  <p><a href="https://i.stack.imgur.com/pGol6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pGol6.png" alt="enter image description here"></a></p>
  
  <p>As you can see symfony has the image so the problem don't come from my app mobile. new UploadedFile(); is the right way ? To upload without form.</p>