1

Possible Duplicate:
POST Content-Length exceeds the limit
PHP Warning: POST Content-Length of 113 bytes exceeds the limit of -1988100096 bytes in Unknown

I have form for upload images, I testing and if I upload image, where have for example 9 mb size, php returns error:

POST Content-Length of 10194008 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

I want that dont upload files more than 2 mb, in first line I have this code:

if (!empty($_FILES['main_photo']['name'])) {

    if ( $_FILES['main_photo']['size'] > 1024 * 1024 * 2 ) {
        header("Location: index.php");
        exit();
    }
}

but this error still displayed, please tell what make, I want if file more than 2 mb, just:

header("Location: index.php");
Community
  • 1
  • 1

3 Answers3

2

In php.ini look for upload_max_filesize and post_max_size and set to a suitable size:

upload_max_filesize = 20M
post_max_size = 20M

Only after that changes you can add your redirection code.


If you can't access your php.ini (shared hosting) try in .htaccess:

php_value upload_max_filesize 20M
php_value post_max_size 20M
Igor Parra
  • 10,214
  • 10
  • 69
  • 101
1

The file you are trying to upload is larger than the configured size set in php.ini. Go inside of php.ini and modify these values to 2mb or greater to allow larger uploads:

upload_max_filesize
post_max_size <-- This one appears to be your biggest issue

Then your code should work.

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
1

Your server probably has setting to limit size to 8 megabytes, I think you code is ok. its a server problem try setting the upload_max_filesize using ini_set to something more. If you are one a commercial server , not your own, try contacting administrator

Dumbo
  • 13,555
  • 54
  • 184
  • 288