title: Yii Framework 2.0 Uploading Files Error finfo_file(): failed to open stream: No such file or directory
body: <p>Following Yii Framework 2.0 documentation <a href="http://www.yiiframework.com/doc-2.0/guide-input-file-upload.html" rel="noreferrer">http://www.yiiframework.com/doc-2.0/guide-input-file-upload.html</a> I tried to upload image. The image could be uploaded successfully, but after uploading the image, I tried to insert the model into the database with the following code.</p>
  
  <pre><code> $model-&gt;file-&gt;saveAs('uploads/' . $model-&gt;file-&gt;baseName . '.' . $model-&gt;file-&gt;extension);
  
   $model-&gt;save();
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code> PHP Warning – yii\base\ErrorException
  
   finfo_file(/tmp/phpIGuwiT): failed to open stream: No such file or directory
  
   1. in /var/www/html/website/advanced/vendor/yiisoft/yii2/helpers/BaseFileHelper.php
   if ($info) {
          $result = finfo_file($info, $file);
          finfo_close($info);
  
          if ($result !== false) {
              return $result;
          }
      }
  
   2. in /var/www/html/my-project/advanced/vendor/yiisoft/yii2/validators/FileValidator.php – yii\helpers\BaseFileHelper::getMimeType()
    $mimeType = FileHelper::getMimeType($file-&gt;tempName, null, false);
  
   3.
   4.
   and so on ....
  </code></pre>
  
  <p>The result is that image has been uploaded but the model has not been inserted into the database. Does anyone know how to solve this?</p>