当我尝试上传大于97.66 KB的文件时,出现此错误(翻译自西班牙语):
“文件太大。文件大小不能超过97.66 Kib。”
这是我的小部件设置:
Modal::begin([
//'title'=>'File Input inside Modal',
'header' => 'Agregar foto',
'toggleButton' => [
'label'=>'Agregar foto',
'class'=>'btn btn-default',
//'href' => Url::to(['afiliado/foto']),
'value' => Url::to('index.php?r=afiliado/foto&id=' . $model->id),
],
]);
echo $form->field($model, 'image')->widget(FileInput::classname(), [
'options' => ['accept' => 'image/*'],
'pluginOptions'=>[
'maxFileCount' => 1,
'allowedFileExtensions'=>['jpg','jpeg','gif','png'],
'showUpload' => false,
'maxImageWidth' => 2400,
'maxImageHeight' => 2400,
'resizeImage' => true,
'maxFilePreviewSize' => 10240,
'minImageWidth' => 50,
'minImageHeight'=> 50,
'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ',
'maxFileSize' => 1024
],
]);
Modal::end();
然后在我的php.ini中设置:
upload_max_filesize = 99MB
post_max_size = 100MB
谢谢。
答案 0 :(得分:1)
您需要使用UploadedFile::getInstance('image')
获取文件,并更改模型规则以在maxSize
附近使用1024 * 1024 * 100
来设置100MB
附近的限制
[['image'],
'file',
'skipOnEmpty' => false,
'extensions' => 'jpg, png, gif, jpeg',
'maxSize' => 1024 * 1024 * 100,
'tooBig' => 'The file was larger than 100MB. Please upload a smaller file.',
],