title: How to read a uploaded file ($_FILE) with Spout
body: <p>I am trying to make a page where the user can upload a correctly formatted Excel file (described in the manual) and let the file be inserted into the database.</p>
  <p>I think I am able to insert the file into the database once Spout can read it but that part doesn't work. Can someone help me.</p>
  <p>Edit: If it is of concern, the server where this program is on is shared.</p>
  <p>Code:</p>
  <pre><code>// (1) FILE CHECK
  // * HTML file type restriction can still miss at times
  if (!isset($_FILES['upexcel']['tmp_name']) || !in_array($_FILES['upexcel']['type'], [
    'text/x-comma-separated-values',
    'text/comma-separated-values',
    'text/x-csv',
    'text/csv',
    'text/plain',
    'application/octet-stream',
    'application/vnd.ms-excel',
    'application/x-csv',
    'application/csv',
    'application/excel',
    'application/vnd.msexcel',
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  ])) {
    die(&quot;Invalid file type&quot;);
  }
  
  require_once &quot;../database.php&quot;;
  require_once '/src/Spout/Autoloader/autoload.php';
  
  
  use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
  
  $reader = ReaderEntityFactory::createReaderFromFile($_FILES['upexcel']['tmp_name']);
  
  $reader-&gt;open($_FILES['upexcel']['tmp_name']);
  foreach ($reader-&gt;getSheetIterator() as $sheet) {
      foreach ($sheet-&gt;getRowIterator() as $row) {
          // do stuff with the row
          $cells = $row-&gt;getCells();
          echo &quot;&lt;/br&gt; Hello&quot; .$cells;
      }
  }
  
  $reader-&gt;close();
  </code></pre>