Yii + CuploadedFIle + POST Content-Length of X bytes exceeds the limit of Y bytes in Unknown on line 0

1k views Asked by At

if i use in validation rule for my file to upload

array('taskfile', 'file', 'allowEmpty' => true, 'maxSize' => 1024 * 1024 * 1)

if maxSize < file size < max_pos the correct error displays but if maxSize < max_post_size < file size then i receive no error messagre but a php warning at the top of my site.

Warning: POST Content-Length of 41816263 bytes exceeds the limit of 15728640 bytes in Unknown on line 0

upload_max_filesize and post_max_size are set in the php.ini. i also tried this workaround with an own vaildation rule, but it doesnt work either.

 public function checkMaxFileSize($attribute) {
    $max_post_size = 1024 * 1024 * ini_get('post_max_size');
    $file_is_too_big = ($_SERVER['CONTENT_LENGTH'] > $max_post_size) ? true : false;

    if ($file_is_too_big)
        $this->addError($attribute, "too big");

the error is also display if yii is not in debug mode.

1

There are 1 answers

1
Brett Gregson On

Try setting your post_max_size/upload_max_filesize in your .htaccess file

php_value post_max_size 10M
php_value upload_max_filesize 10M