I have written a file uploader for a custom app that breaks the file up into chunks and sends it to the server via ajax. The issue I have is that I can pull the upload_max_filesize and post_max_size using ini_get, however, I cannot seem to get the client_max_body_size that nginx uses to dole out the 413 errors; and the answer space is polluted with people trying to up the limit. I want my software to detect and work around the limit (since it already chunks things so well). How can I detect client_max_body_size (or any other potential limit values) as a value in php (ideally in a generic manner that doesn't require modifying nginx files, so that code is drop in ready for the public, but i'll take what I can get). Thanks in advance!
Asked
Active
Viewed 1,623 times
3
-
If it's not available as a PHP ini variable you could may need to run a command that dumps nginx config values [e.g. `exec('nginx -T')`](https://stackoverflow.com/questions/12832033/dump-conf-from-running-nginx-process) and grep/parse it for the value you want – scrowler Aug 26 '18 at 23:39
-
1I think you can only get PHP's `upload_max_filesize` unless you make a configuration change to nginx's conf file to pass that value in `$_SERVER` or similar, but it would not be helpful with your generic approach – Cemal Aug 26 '18 at 23:40
-
exec doesn't seem like a good idea. I get permission denied... If I have to go that far out of my way I guess I can see why everybody wants to up that limit... Thank you for the idea however. – Jarrod Juleff Aug 27 '18 at 04:42
1 Answers
0
I guess the most sensible thing to do then is to hard code it in the config so that people can target their environments to their limitations manually. I was hoping there was a better generic solution, but I guess there is not.

Jarrod Juleff
- 75
- 8