I am developing an application in Yii2 framework.
I am uploading an image using code below and which has worked perfect till now. But now I got an error instant. I don't understand what has happened.
Below is the code of controller where upload file and save take place:
// Upload photo of subcategories...
$model->file = UploadedFile::getInstance($model, 'file');
if($model->file) {
$imageName = rand(1000,100000);
$model->file->saveAs('uploads/subcategories/'.$imageName.'.'.$model->file->extension);
$model->sub_category_photo = 'uploads/subcategories/'.$imageName.'.'.$model->file->extension;
}
$model->save();
I got below error:
PHP Warning – yii\base\ErrorException finfo_file(C:\xampp\tmp\php9A7B.tmp): failed to open stream: No such file or directory
I also un-comment extension = fileinfo.dll in php.ini file and restart server.