Shirish Bathe
Shirish Bathe

Reputation: 637

Yii2 File upload is not working with large files

I am trying to upload image file to web server. I am using Yii2 framework. I am able to upload small files without any problem, whereas if I am uploading large file, It is not getting upload. I am able to see progress bar in browser while file is getting uploaded. but after completion of file upload, file is not saved on server as well as browser displays blank screen instead of index.php but debug message (Check point 1 **) is logged in log file.

Here is code fragment for your reference.

        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,
        ]);
    }

Upvotes: 1

Views: 2292

Answers (2)

Moneer Kamal
Moneer Kamal

Reputation: 1877

please check this in your php.ini

  upload_max_filesize = 64M

and edited to be as larg as you need

Upvotes: 1

vijay nathji
vijay nathji

Reputation: 1638

You need to change this in the php.ini:

max_execution_time = 30

Or

In your php script:

set_time_limit(180); // Set max execution time 3 minutes.

Upvotes: 1

Related Questions