doucan4815 2016-04-30 23:06
浏览 73
已采纳

fileinfo PHP扩展未安装在真实服务器中

have a problem of my excel file uploading. code is working perfectly in my localhost but not in the real server. this is my controller code:

class UploadController extends \yii\web\Controller
{
  public function actionIndex()
{
    $model = new UploadForm();
    if (Yii::$app->request->isPost) {
        $model->excelFile = UploadedFile::getInstance($model, 'excelFile');
        if ($model->upload()) {
            $query = Yii::$app->db->createCommand('SHOW TABLES FROM reporting')
                                                    ->queryAll();
                if ($query==null) {
                    $nodb="no";
                    return $this->render('index',['model' => $model,'nodb' => $nodb,]);
                }else{
                    $this->redirect(URL_FOLDER.'backend/controllers/import.php?filename='.$model->excelFile.'&dbname='.DB_NAME);
                }
        }
    }
    return $this->render('index',['model' => $model,]);
}

}

end this is my models code:

class UploadForm extends Model
{
/**
 * @var UploadedFile
 */
public $excelFile;

public function rules()
{
    return [
        [['excelFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'xls'],
    ];
}

public function upload()
{
    if ($this->validate()) {
        $this->excelFile->saveAs('uploads/' . $this->excelFile->baseName . '.' . $this->excelFile->extension);
        return true;
    } else {
        return false;
    }
}
}

i tried with solution in the duplicate question but it was not helpful, and can't found the php.ini in the real server

  • 写回答

2条回答 默认 最新

  • dongre8505 2016-05-05 09:28
    关注

    my solution to that is : in home page of cPanel go to : logiciel => select PHP version and a list of extension diplay to you, you can select what you need like that: enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog