title: file upload mime type issue with UploadedFile
body: <p>I am using <code>UploadedFile</code> class in symfony2 to upload image files. I have allowed images with mime type <code>image/jpg</code> and <code>image/png</code>. When I upload a png file from my system to server its mime type is changed automatically. I know its changed because when I fire this command:</p>
  
  <pre><code>file --mime-type /home/mysuer/img.png
  </code></pre>
  
  <p>it gives me this:</p>
  
  <pre><code>home/myuser/img.png: image/png
  </code></pre>
  
  <p>but when I upload file and print <code>UploadedFile</code> object it gives following output:</p>
  
  <pre><code>Array
  (
      [media] =&gt; Symfony\Component\HttpFoundation\File\UploadedFile Object
          (
              [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 
              [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; img.png
              [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; application/octet-stream
              [size:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 1246
              [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 0
              [pathName:SplFileInfo:private] =&gt; /tmp/phpivgnne
              [fileName:SplFileInfo:private] =&gt; phpivgnne
          )
  
  )
  </code></pre>
  
  <p>Can any one suggest what's wrong?</p>
  
  <h2>EDIT</h2>
  
  <p>Here is my Code:</p>
  
  <pre><code>public function postFileAction(Request $request)
  {
      print_r($request-&gt;files-&gt;all());//Prints All files
  
  
      $image = $request-&gt;files-&gt;get('media');
      echo $image-&gt;getClientMimeType();exit; //Mime Type Information
  
      if (empty($image)) {
          throw new FileException('Invalid File, Please Select a Valid File.');
      }
  
      $uploader = $this-&gt;get('application.file_uploader');
  
      if (!$this-&gt;container-&gt;get('security.context')-&gt;isGranted('IS_AUTHENTICATED_FULLY')) {
          //authenticated (NON anonymous users)
          throw new InvalidParameterException('Invalid User, Please use valid credentials');
      }
  
      return $uploader-&gt;upload($image, $this-&gt;get('security.context')-&gt;getToken()-&gt;getUser()-&gt;getId());
  }
  </code></pre>
  
  <p>PHPUnit Test Code</p>
  
  <pre><code>public function testPostFile()
  {
      $file    = tempnam(sys_get_temp_dir(), 'upl'); // create file
      imagepng(imagecreatetruecolor(10, 10), $file); // create and write image/png to it
      $image   = new UploadedFile($file, 'new_image.png', 'image/png', 10, UPLOAD_ERR_OK);
      $crawler = $this-&gt;client-&gt;request(
              'POST', '/api/v1/files.json', array('submit' =&gt; 'Submit Form'), array('media' =&gt; $image)
      );
  
      $response = $this-&gt;client-&gt;getResponse();
  
      $this-&gt;assertJsonResponse($response);
      $this-&gt;assertContains('filename', $response-&gt;getContent());
  
      print_r($response-&gt;getContent());exit;
  
      $fileToken = json_decode($response-&gt;getContent());
      $this-&gt;assertNotEmpty($fileToken-&gt;filename);
  
      unlink($file);
      unset($file, $image, $crawler, $response);
  
      return $fileToken-&gt;filename;
  }
  </code></pre>
  
  <p>I am using <code>curl</code> from command prompt to test my REST web service file upload like this:</p>
  
  <pre><code>curl -X POST myapi.com/app_dev.php/api/v1/files.json --form "media=@/home/myuser/img.png"
  </code></pre>