Error when Updloading Image 3MB or more


 [['photo'], 'file', 'mimeTypes' => 'image/jpeg, image/png,image/gif,image/jpg', 'extensions' => 'png,jpg,jpeg,gif', 'maxFiles' => 1,'maxSize'=>5000000,'skipOnEmpty'=>true],

Above is the rule for the field that receives the image; but when I try to upload a photo that’s 3MB or above I am getting this below error;


An Error occurred while handling another error:

exception 'yii\web\ForbiddenHttpException' with message 'You are not allowed to perform this action.' in C:\wamp\www\pub\vendor\yiisoft\yii2\filters\AccessControl.php:151

Stack trace:

#0 C:\wamp\www\pub\vendor\yiisoft\yii2\filters\AccessControl.php(134): yii\filters\AccessControl->denyAccess(Object(yii\web\User))

#1 C:\wamp\www\pub\vendor\yiisoft\yii2\base\ActionFilter.php(71): yii\filters\AccessControl->beforeAction(Object(yii\web\ErrorAction))

#2 [internal function]: yii\base\ActionFilter->beforeFilter(Object(yii\base\ActionEvent))

#3 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Component.php(541): call_user_func(Array, Object(yii\base\ActionEvent))

#4 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Controller.php(263): yii\base\Component->trigger('beforeAction', Object(yii\base\ActionEvent))

#5 C:\wamp\www\pub\vendor\yiisoft\yii2\web\Controller.php(108): yii\base\Controller->beforeAction(Object(yii\web\ErrorAction))

#6 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Controller.php(149): yii\web\Controller->beforeAction(Object(yii\web\ErrorAction))

#7 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('error', Array)

#8 C:\wamp\www\pub\vendor\yiisoft\yii2\web\ErrorHandler.php(85): yii\base\Module->runAction('site/error')

#9 C:\wamp\www\pub\vendor\yiisoft\yii2\base\ErrorHandler.php(109): yii\web\ErrorHandler->renderException(Object(yii\web\BadRequestHttpException))

#10 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\BadRequestHttpException))

#11 {main}

Previous exception:

exception 'yii\web\BadRequestHttpException' with message 'Unable to verify your data submission.' in C:\wamp\www\pub\vendor\yiisoft\yii2\web\Controller.php:110

Stack trace:

#0 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Controller.php(149): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))

#1 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('create', Array)

#2 C:\wamp\www\pub\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('activite/create', Array)

#3 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))

#4 C:\wamp\www\pub\web\index.php(12): yii\base\Application->run()

#5 {main}</pre>

I tried to check my php.ini max upload for file; I found it’s set to : upload_max_filesize = 64M;

I wonder where the problem is.

You need to set the value of upload_max_filesize and post_max_size in your php.ini :

; Maximum allowed size for uploaded files.

upload_max_filesize = 64M

; Must be greater than or equal to upload_max_filesize

post_max_size = 64M

do you?

And then check also access rules in your controller. For example you try to perform login action when you are already logged in.

I checked and found that post_max_size = 3M and then changed it to 64M but still getting the same error and javascript is also showing


Uncaught TypeError: Cannot read property 'files' of undefined

error in the browser