title: Why does PhpSpreadsheet fail to identify my Xlsx file in public://?
body: <p>I'm working on a Drupal module that imports a Xlsx file and inserts the rows to database. Everything works fine, except PhpSpreadsheet throws the error <code>"PHP message: Uncaught PHP Exception InvalidArgumentException: "File "" does not exist." at File.php line 137"</code> when my uploaded file is in <code>public</code>. This error doesn't happen when the file is in <code>base_path()</code>. Line 137 throws an exception saying it's not a file, but <code>\dpm(is_file($uri))</code> returns <code>TRUE</code>. Why is this happening? Below is my code:</p>
  
  <pre><code>public function submitForm(array &amp;$form, FormStateInterface $form_state) {
      $connection = \Drupal::database();
      $fid = $form_state-&gt;getValue("xlsx_upload");
      $input = File::load(reset($fid));
      $input-&gt;setPermanent();
      $uri = \Drupal::service('file_system')-&gt;realpath($input-&gt;getFileUri());
      //$uri = '/home/joe/file.xslx'; &lt;--- this works perfectly.
      $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile($uri);
      $spreadsheet = $reader-&gt;load($filename);
      $dataArray = $spreadsheet-&gt;getActiveSheet()-&gt;toArray();
      $connection-&gt;truncate("mitacan")-&gt;execute();
      $connection-&gt;query("SET NAMES utf8");
      foreach ($dataArray as $dataItem) {
        $connection-&gt;insert('mitacan')
        -&gt;fields([
          'stokkodu'      =&gt; $dataItem[0],
          'logo'          =&gt; $dataItem[1],
          'resim1'        =&gt; $dataItem[2],
          'grupkodu'      =&gt; $dataItem[3],
          'grupadi'       =&gt; $dataItem[4],
          'grupindex'     =&gt; $dataItem[5],
          'paketadedi'    =&gt; $dataItem[6],
        ])
        -&gt;execute();
      }
      drupal_set_message('Excel verisi veritabanına eklendi.');
    }
  </code></pre>