title: Having trouble with Symfony2 uploading file from external program - 'mimeType' => 'application/octet-stream'
body: <p>I have a Symfony2 endpoint that needs to accept a post request with a few text parameters and a zip file delivered by a 3rd party program. For quick development I started out by just using a Chrome POST plugin to spoof sending the form data. I was able to retrieve the file just fine when using that method.</p>
  
  <p>However, when I switched to the 3rd party Windows application for uploading reports, I'm no longer able to retrieve the file. Instead of figuring out that it's a zip file, I now get <code>mimeType' =&gt; 'application/octet-stream'</code>, and the file size is 0.</p>
  
  <p>I read here in the following link that I needed to make sure my post_max_size and upload_max_filesize were large enough to handle the file. <a href="https://stackoverflow.com/questions/27268058/cant-upload-image-with-mime-type-application-octet-stream-in-symfony2">Can&#39;t upload image with mime-type &quot;application/octet-stream&quot; in Symfony2</a></p>
  
  <p>I didn't want to mess around, so I set it to 100mb, but still no luck.</p>
  
  <p>Here is a dump of the Request:</p>
  
  <pre><code>[2016-08-24 10:15:48] app.INFO: Request dump: Symfony\Component\HttpFoundation\Request::__set_state(array(    'attributes' =&gt;    Symfony\Component\HttpFoundation\ParameterBag::__set_state(array(      'parameters' =&gt;      array (       '_format' =&gt; 'xml',       '_controller' =&gt; 'Company\\Bundle\\CompanyBundle\\Controller\\DefaultController::cloudTransferReport',       '_route' =&gt; 'hg_cloudtransfer_report',       '_route_params' =&gt;        array (         '_format' =&gt; 'xml',       ),       '_method' =&gt;        Sensio\Bundle\FrameworkExtraBundle\Configuration\Method::__set_state(array(          'methods' =&gt;          array (           0 =&gt; 'POST',           1 =&gt; 'GET',         ),       )),     ),   )),    'request' =&gt;    Symfony\Component\HttpFoundation\ParameterBag::__set_state(array(      'parameters' =&gt;      array (       'submitter' =&gt; 'hgis',       'version' =&gt; '5.1.26.0',       'userName' =&gt; 'admin',       'password' =&gt; 'kitten',     ),   )),    'query' =&gt;    Symfony\Component\HttpFoundation\ParameterBag::__set_state(array(      'parameters' =&gt;      array (     ),   )),    'server' =&gt;    Symfony\Component\HttpFoundation\ServerBag::__set_state(array(      'parameters' =&gt;      array (       'REDIRECT_HTTPS' =&gt; 'on',       'REDIRECT_SSL_TLS_SNI' =&gt; 'example.com',       'REDIRECT_STATUS' =&gt; '200',       'HTTPS' =&gt; 'on',       'SSL_TLS_SNI' =&gt; 'example.com',       'CONTENT_TYPE' =&gt; 'multipart/form-data, boundary=AaBbCcDdHhGg40',       'HTTP_USER_AGENT' =&gt; 'Some software v 5.1.26.0',       'HTTP_HOST' =&gt; 'example.com',       'CONTENT_LENGTH' =&gt; '3592731',       'HTTP_CACHE_CONTROL' =&gt; 'no-cache',       'PATH' =&gt; '/usr/bin:/bin:/usr/sbin:/sbin',       'SERVER_SIGNATURE' =&gt; '',       'SERVER_SOFTWARE' =&gt; 'Apache/2.4.18 (Unix) PHP/5.5.36 LibreSSL/2.2.7',       'SERVER_NAME' =&gt; 'example.com',       'SERVER_ADDR' =&gt; '192.168.1.100',       'SERVER_PORT' =&gt; '443',       'REMOTE_ADDR' =&gt; '192.168.1.223',       'DOCUMENT_ROOT' =&gt; '/Users/user/Documents/symphony/cpsrecall/web',       'REQUEST_SCHEME' =&gt; 'https',       'CONTEXT_PREFIX' =&gt; '',       'CONTEXT_DOCUMENT_ROOT' =&gt; '/Users/user/Documents/symphony/cpsrecall/web',       'SERVER_ADMIN' =&gt; 'chris@yourcontactpoint.com',       'SCRIPT_FILENAME' =&gt; '/Users/user/Documents/symphony/cpsrecall/web/app.php',       'REMOTE_PORT' =&gt; '51248',       'REDIRECT_URL' =&gt; '/hg/cloudtransfer/upload-report',       'GATEWAY_INTERFACE' =&gt; 'CGI/1.1',       'SERVER_PROTOCOL' =&gt; 'HTTP/1.1',       'REQUEST_METHOD' =&gt; 'POST',       'QUERY_STRING' =&gt; '',       'REQUEST_URI' =&gt; '/hg/cloudtransfer/upload-report',       'SCRIPT_NAME' =&gt; '/app.php',       'PHP_SELF' =&gt; '/app.php',       'REQUEST_TIME_FLOAT' =&gt; 1472055346.6129999,       'REQUEST_TIME' =&gt; 1472055346,     ),   )),    'files' =&gt;    Symfony\Component\HttpFoundation\FileBag::__set_state(array(      'parameters' =&gt;      array (       'file1' =&gt;        Symfony\Component\HttpFoundation\File\UploadedFile::__set_state(array(          'test' =&gt; false,          'originalName' =&gt; '00000003-1.zip',          'mimeType' =&gt; 'application/octet-stream',          'size' =&gt; 0,          'error' =&gt; 1,       )),     ),   )),    'cookies' =&gt;    Symfony\Component\HttpFoundation\ParameterBag::__set_state(array(      'parameters' =&gt;      array (     ),   )),    'headers' =&gt;    Symfony\Component\HttpFoundation\HeaderBag::__set_state(array(      'headers' =&gt;      array (       'content-type' =&gt;        array (         0 =&gt; 'multipart/form-data, boundary=AaBbCcDdHhGg40',       ),       'user-agent' =&gt;        array (         0 =&gt; 'Some software v 5.1.26.0',       ),       'host' =&gt;        array (         0 =&gt; 'example.com',       ),       'content-length' =&gt;        array (         0 =&gt; '3592731',       ),       'cache-control' =&gt;        array (         0 =&gt; 'no-cache',       ),       'x-php-ob-level' =&gt;        array (         0 =&gt; 1,       ),     ),      'cacheControl' =&gt;      array (       'no-cache' =&gt; true,     ),   )),    'content' =&gt; '',    'languages' =&gt; NULL,    'charsets' =&gt; NULL,    'encodings' =&gt; NULL,    'acceptableContentTypes' =&gt; NULL,    'pathInfo' =&gt; '/hg/cloudtransfer/upload-report',    'requestUri' =&gt; '/hg/cloudtransfer/upload-report',    'baseUrl' =&gt; '',    'basePath' =&gt; NULL,    'method' =&gt; 'POST',    'format' =&gt; NULL,    'session' =&gt;    Symfony\Component\HttpFoundation\Session\Session::__set_state(array(      'storage' =&gt;      Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::__set_state(array(        'bags' =&gt;        array (         'attributes' =&gt;          Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::__set_state(array(            'name' =&gt; 'attributes',            'storageKey' =&gt; '_sf2_attributes',            'attributes' =&gt;            array (           ),         )),         'flashes' =&gt;          Symfony\Component\HttpFoundation\Session\Flash\FlashBag::__set_state(array(            'name' =&gt; 'flashes',            'flashes' =&gt;            array (           ),            'storageKey' =&gt; '_sf2_flashes',         )),       ),        'started' =&gt; false,        'closed' =&gt; false,        'saveHandler' =&gt;        Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy::__set_state(array(          'handler' =&gt;          SessionHandler::__set_state(array(         )),          'wrapper' =&gt; true,          'active' =&gt; false,          'saveHandlerName' =&gt; 'files',       )),        'metadataBag' =&gt;        Symfony\Component\HttpFoundation\Session\Storage\MetadataBag::__set_state(array(          'name' =&gt; '__metadata',          'storageKey' =&gt; '_sf2_meta',          'meta' =&gt;          array (           'c' =&gt; 0,           'u' =&gt; 0,           'l' =&gt; 0,         ),          'lastUsed' =&gt; NULL,          'updateThreshold' =&gt; '0',       )),     )),      'flashName' =&gt; 'flashes',      'attributeName' =&gt; 'attributes',   )),    'locale' =&gt; NULL,    'defaultLocale' =&gt; 'en', )) [] []
  </code></pre>
  
  <p>and for those who don't want to read that big long line, here's just the FileBag:</p>
  
  <pre><code>[2016-08-24 10:15:48] app.INFO: file1dump: Symfony\Component\HttpFoundation\File\UploadedFile::__set_state(array(    'test' =&gt; false,    'originalName' =&gt; '00000003-1.zip',    'mimeType' =&gt; 'application/octet-stream',    'size' =&gt; 0,    'error' =&gt; 1, )) [] []
  </code></pre>
  
  <p>Here is my code up that should grab the file, but perhaps I'm going about it wrong:</p>
  
  <pre><code>public function cloudTransferReport(Request $request)
  {
      $logger = $this-&gt;get('logger');
      $em = $this-&gt;getDoctrine()-&gt;getManager();
  
      $data = $request-&gt;request;
      $files = $request-&gt;files;
  
      $submitter = $data-&gt;get('submitter');
      $version = $data-&gt;get('version');
      $memberName = $data-&gt;get('userName');
      $password = $data-&gt;get('password');
      $file1 = $files-&gt;get('file1');
  
      $logger-&gt;info("file string: " . var_export($stuff, true));
      $logger-&gt;info("file1dump: " . var_export($file1, true));
  </code></pre>
  
  <p>If you need more code from that controller let me know, but I thought I should at least be able to have the file in memory at this point.</p>