Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The fileinfo PHP extension is not installed in Yii2 error

Tags:

yii2

I have a problem of my file uploading feature attached into my webapp. code is working perfectly in my localhost but not in the real server which i was uploaded already. and i was changed the directory permission to writable.

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

like image 443
asela daskon Avatar asked Jan 11 '16 07:01

asela daskon


1 Answers

I think there is not any issue in your Yii2 code. It may be an issue of PHP configuration.

File Info extension is enabled by default as of PHP 5.3.0

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

Please visit below link for more details.

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

like image 112
AsgarAli Avatar answered Sep 19 '22 17:09

AsgarAli