3

Today i was making a file upload for avatars, everything works great, it resizes the images etc, but occasionally when selecting a large and invalid file it produces this error :

Warning: POST Content-Length of 52091839 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
You did not select a file to upload.

This does not happen all the time, just occasionally. Normally it just gives the correct error message when a file is too big.

Does anyone have an idea where this error comes from, and why it shows?

Thanks!

user1362916
  • 119
  • 2
  • 14
  • If the answer doesn't work you may want to look at http://stackoverflow.com/questions/6315358/php-warning-post-content-length-of-113-bytes-exceeds-the-limit-of-1988100096-b – Sylwester Aug 26 '12 at 18:41

3 Answers3

5

Sounds like you need to increase post_max_size in php.ini. If you have not already also increased upload_max_filesize, you are likely to need to increase it as well.

# php.ini
# Allow huge files:
# Post usually needs to be bigger than file upload size!
post_max_size = 256M
upload_max_filesize 128M
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
  • Thats not the problem i think, because if i have a file that is too big to post it shows the correct error : The uploaded file exceeds the maximum allowed size in your PHP configuration file. this is a different error which i havent setup anywhere – user1362916 Aug 26 '12 at 18:39
  • @user1362916 The two directives will cause different errors. Make sure both are large enough. – Michael Berkowski Aug 26 '12 at 18:41
2

Update your post_max_size in php.ini to a larger value

upload_max_filesize sets the max file size that a user can upload while post_max_size sets the maximum amount of data that can be sent via a POST in a form. That might be the reason why you get big file error sometimes when you try upload a single file of large size but when you try to upload multiple files the above error is raised.

Srijan
  • 1,234
  • 1
  • 13
  • 26
1

This has to do with the way the file is coded when uploaded.

Basically it is "seen" as a very large POST.

So you want your php.ini post_max_size larger than your upload_max_filesize value.

Depending on the encoding you use, it should be from 60% to 100% larger.

Otherwise you might have a max file size of 5 M, but this gets encoded to 8.01 M; when that happens, the check for file size passes, but the one for post body size fails. Hence your error.

LSerni
  • 55,617
  • 10
  • 65
  • 107