CodeIgniter Forums
finfo_file(): Empty filename or path in CodeIgniter 4.0.4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: Issues (https://forum.codeigniter.com/forum-19.html)
+--- Thread: finfo_file(): Empty filename or path in CodeIgniter 4.0.4 (/thread-77155.html)



finfo_file(): Empty filename or path in CodeIgniter 4.0.4 - anggakswr - 07-26-2020

I'm having this error when I try to upload 1 image in CodeIgniter 4.0.4.

[Image: xp1jT.png]


SYSTEMPATH/Files/File.php at line 153
Code:
152         $finfo    = finfo_open(FILEINFO_MIME_TYPE);
153         $mimeType = finfo_file($finfo, $this->getRealPath());
154         finfo_close($finfo);
155         return $mimeType;


This is my code:
Code:
if ($img = $this->request->getFile('foto')) {
  if ($img->isValid() && !$img->hasMoved()) {
    $img->move('img/uploads/user');
    $namaFoto = $img->getName();
  }
} else {
  $namaFoto = 'user.png';
}


But when I try to upload multiple images, it works fine. This is the code to upload multiple images:
Code:
$fileFoto = $this->request->getFileMultiple('foto');

foreach ($fileFoto as $foto) {
    if ($foto->isValid() && !$foto->hasMoved()) {
      $foto->move('img/uploads/barang');
      $this->fotoModel->save([
        'slug' => $slug,
        'foto' => $foto->getName()
      ]);
    }
}


Is there a problem when CodeIgniter upgrade to version 4.0.4 because I did not experience problems when uploading a single file in version 4.0.3.