[英]Yii2 File upload is not working with large files
我正在尝试将图像文件上传到Web服务器。 我正在使用Yii2框架。 我可以上传小文件而没有任何问题,但是如果我上传大文件,则不会上传。 上传文件时,我能够在浏览器中看到进度条。 但文件上传完成后,文件未保存在服务器上,浏览器显示空白屏幕而不是index.php,但调试消息(检查点1 **)记录在日志文件中。
这是代码片段供您参考。
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,
]);
}
您需要在php.ini中进行更改:
max_execution_time = 30
要么
在您的PHP脚本中:
set_time_limit(180); // Set max execution time 3 minutes.
请在您的php.ini中检查
upload_max_filesize = 64M
并根据您的需要进行编辑
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.