Yii 2.0 Framework中大型文件无法上传

时间:2016-07-09 09:43:34

标签: php file-upload yii

大型pdf文件未在Yii2 Framework中上传。

上传时遇到错误

错误:fopen(importclaimattachment / Testing Results - Phase II.pdf):无法打开流:没有这样的文件或目录

如果文件大小低于2MB正在上传,则超过2MB不上传

控制器代码:

$model->attachment_to_be_stored = UploadedFile::getInstances($model, 'attachment_to_be_stored');
foreach ($model->attachment_to_be_stored as $file) 
                            {
                                $file->saveAs('importclaimattachment/' .$file->baseName. '.' . $file->extension);
                                $filename = 'importclaimattachment/' .$file->baseName. '.' . $file->extension;
                                $value->attach($filename);
                            }

型号代码:

['attachment_to_be_stored', 'file', 'extensions' => ['pdf', 'docx'], 
            'maxSize' => 1024 * 1024 * 5, 'maxFiles'=>1000],

表单代码:

<?php
          echo $form->field($model, 'attachment_to_be_stored[]')->widget(FileInput::classname(), [
              'options' => ['multiple' => true],
              'pluginOptions' => [
                'previewFileType' => 'any',
                'allowedFileExtensions' => ['pdf','docx'],
                'maxFileSize' => 5120,
              ]
          ]);
    ?>

坚持这个......帮助将非常感激。

0 个答案:

没有答案