2

Large size pdf file not uploading in Yii2 Framework.

While Uploading am getting below error

ERROR : fopen(importclaimattachment/Testing Results - Phase II.pdf): failed to open stream: No such file or directory

if the file size is below 2MB is uploading, more than 2MB is not uploading

Controller Code:

$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);
                            }

Model Code:

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

Form Code:

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

Am stuck with this..Help will be really appreciated.

Nodemon
  • 1,036
  • 2
  • 25
  • 47

0 Answers0