S
S
Scuba2018-05-16 08:26:08
PHP
Scuba, 2018-05-16 08:26:08

When sending a bulk POST, we get a 404 error, why?

Hello! I have a vizivig editor on my site.
When I insert a picture from a computer there, the editor creates an img tag, and as src prescribes the content of the picture encoded in base64. That is, even if you insert a 2x2 pixel image, the number of characters that the vizivig-editor generates is more than a hundred.
The problem is that if you try to insert a large image that weighs 1.5 megabytes and submit the form, it redirects to a 404 error . Because in this case, the number of characters will be almost 2 million. And I'm trying to transfer these two million to POST.
Error log is empty. After submitting the form, I try to display all the data simply throughprint_r($_POST), and even in this case, a redirect to 404 occurs with a large picture, but everything is fine with a small one.
Are there any limits on the length of a string in a POST? Or is there some client-side solution so that before submitting the form, the images are compressed somehow or redrawn to a lower resolution, for example, using JS?
UPD: Added source code.

<form method="POST" action="/cabinet/new/" id="new_case" autocomplete="off" enctype="multipart/form-data">
  <textarea id="summernote" name="new_case_body"></textarea>
  <input type="submit" name="new_case" id="fs" value="Сохранить">
</form>

And the handler:
if (isset($_POST['new_case'])) {
  print_r($_POST);exit;
}

It should be noted that the server has a CNC.
That is, in the action of the form I have /cabinet/new/, and in fact the server sends to /index.php?r=/cabinet/new/ and then through require I load the necessary module, for example, cabinet_new.php
It works like this:
RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,R=301,L] 

RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f     
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
RewriteRule \.(php|html|swf|fla|xml|ico|jpg|gif|png|txt|js|css|eot|ttf|woff|map)$ - [L]
RewriteRule ^(.*)$ index.php?r=$1 [L,QSA]

The settings are:
memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 2M

UPD2 Did
a test. I insert 1,000,000 characters (almost 1MB) into the text field, everything works fine.
I insert a little more - 1,100,000, send the form - a redirect to 404.
This means that somewhere there is a limit on the POST length over 1MB.
Tech support says there are no restrictions.
Increased upload_max_filesize to 16M, still 404

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksim Fedorov, 2018-05-16
@Maksclub

post_max_size
php.net/manual/ru/ini.core.php#ini.post-max-size
There is also max_upload_filesize

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question