title: how to upload image to symfony php server
body: <p>I have this code that works:</p>
  
  <pre><code>session_start();     
  if ( isset($_SESSION['username']) ) {
      $params = explode(".", basename($_FILES["file"]["name"]));
      $target = array_values($params)[0];
      $id = array_values($params)[1];
      if ( ($target == "profile") || ($target == "question" &amp;&amp; $_SESSION["waitingImagesQuestion"] &gt; 0) || ($target == "answer" &amp;&amp; $_SESSION["waitingImagesAnswer"] &gt; 0) ) {
          $imageDirectory = "images/".round(microtime(true)*1000).".png";
          if ( move_uploaded_file($_FILES["file"]["tmp_name"], $imageDirectory) ) {
              print "success";
  
          } 
      }
  } 
  print JsonBuilder::getStringError();
  </code></pre>
  
  <p>Now I want the code that do the same with symfony. 
  How can I write it?</p>
  
  <p>thanks</p>