我想将图像文件上传到网络服务器。我正在使用Yii2框架。我可以毫无问题地上传小文件,而如果我正在上传大文件,则无法上传。当文件上传时,我可以在浏览器中看到进度条。但文件上传完成后,文件不会保存在服务器上,浏览器也会显示空白屏幕而不是index.php,但在日志文件中会记录调试消息(检查点1 **)。Yii2文件上传不适用于大文件
这里是代码片段供您参考。
if ($model->load($_POST) && $model->save()) {
$arrFile = UploadedFile::getInstance($model, 'file_location');
if (!empty($arrFile)) {
$model->file_location = $arrFile;
$strFileName = $model->file_location->baseName . '.' . $model->file_location->extension;
Yii::error('Check point 1 ************* '. $strFileName);
if ($model->file_location->saveAs('uploads/newsletters/' . $strFileName)) {
$model->file_location = $strFileName;
$model->save();
return $this->redirect('index');
//return $this->redirect(['view', 'id' => $model->id]);
}
} else {
return $this->redirect('index'); //$this->redirect(['view', 'id' => $model->id]);
}
} else {
return $this->render('create', [
'model' => $model,
]);
}
您可以检查您的服务器的最大文件上传大小吗? –
@ManikandanS:我没有在代码中指定任何大小限制。还有可用磁盘空间超过5GB。 –
您必须按照下面的答案关注@MoneerKamal指令,更改值后请重新启动apache服务器。 –