PHP fileinfo extension not installed in Yii2 error

I have a problem with the file upload function attached to my webapp. The code works fine in my localhost, but not on the real server that I already downloaded. and I changed the permissions on the directories to write.

if ($model->load(Yii::$app->request->post())) 
    {   
       $session = Yii::$app->session;
       $user_id = $session->get('role');

        //get the instance of the uploaded file
        $imageName = $model->Fname."_".$model->Lname;

        $model->file = UploadedFile::getInstance($model, 'file');

        if($model->file)
        {    
          //SHA512 base password encription
          $model->password = crypt($model->repeatpassword,'$6$rounds=1212$16charactersalt');

          //save image pathe to db
          $model->image = 'uploads/profile_image/'.$imageName.'.'.$model->file->extension;
          $model->role = $user_id;
          $model->save();
          $model->file->saveAs( 'uploads/profile_image/'.$imageName.'.'.$model->file->extension );  
        }          
        //return $this->redirect(['index']);
        return $this->goHome();
    } 

Login form

After submitting the form

+4
source share
2 answers

I think there is no problem in your Yii2 code. This may be a PHP configuration problem.

File information is added by default with PHP 5.3.0

Windows users must include the associated php_fileinfo.dll DLL in php.ini in order to enable this extension.

See below for more details.

http://php.net/manual/en/fileinfo.installation.php

+2
source

php.ini :

extension=php_fileinfo.dll
+1

Source: https://habr.com/ru/post/1623708/


All Articles