I am trying to upload a file using uppy. On my server I am using php 8.0 and Apache 2.
I am uploading a file which is about 156Mb in size but server returns response with 413 status code and no message.
As per instruction given on all over internet I tried to configure my php.ini file and here are the updated configurations
post_max_size = 20480M
upload_max_filesize = 20480M
max_execution_time = 24000
max_input_time = 24000
memory_limit = 800M
Unfortunately above settings didn't help me. I have confirmed the php.ini file location with following command
php -i | grep Conf
Apart from this, I came across an answer that asked to set SecRequestBodyLimit value in modsecurity.conf. modsecurity was not even installed in my system but still I installed it and set the SecRequestBodyNoFilesLimit value as SecRequestBodyLimit 1000000000 but no luck.
I highly doubt that this is from server and Uppy has no role in this issue but I cannot predict the exact problem.
Response 413 is a typical error when you use ModSecurity, and the limit was set incorrectly. You should review the relevant documentation. If the size of your file is 156MB, you should calculate the base64 encoded size: multiply it with 4 and divide it by 3, so the approximate value is 208MB. I should set up 250MB for SecRequestBodyLimit, but not for SecRequestBodyNoFilesLimit - please keep it as low. 250MB is 262144000 byte, so try to set up this:
SecRequestBodyLimit 262144000
Also please check your Apache's error.log, you have to see every relevant information there.
Related
I want to import a file(85 MB) at my local server.
I changed in the php.ini the following values of the three variables (upload_max_filesize, memory_limit and post_max_size) exactly as I saw at same problems, with the right order, I restarted my MAMP server and my laptop but it didn't change anything and I can't import files more than 2 MB.
Can you give any advise to fix it ?
You need to edit the php.ini file for the php version you are using. i.e. v7.2.1.
First check which version you're using by going to
MAMP-> Preferences -> PHP -> Select/Specify PHP Version
Then go to /Applications/MAMP/bin/php/php7.2.10/conf/php.ini and input the new settings there.
Stop your server and restart MAMP. Import should now run as expected.
Cheers.
Once you find out which version of PHP your MAMP is running, find the php.ini file at C:\MAMP\conf\php7.2.10\php.ini.
You'll need to change BOTH upload_max_filesize and post_max_size. If you only update the first, it'll default to the post_max_size.
Restart the MAMP and you should be good to go.
First check your PHP version
then according to your php version you have to go this php version file (php.ini)
and the change like below... :)
post_max_size = 256M
; Maximum allowed size for uploaded files.
upload_max_filesize = 256M
; Maximum execution time of each script, in seconds
max_execution_time = 600
; Maximum amount of time each script may spend parsing request data
max_input_time = 600
; Maximum amount of memory a script may consume (8MB)
memory_limit = 512M
I did all these things but nothing happened.I have two files with the name "php.ini",the first is "php.ini-development" and the second is "php.ini-production".Because i don't know which is the correct file to change the values,i changed the values and at the two because my phpinfo have like a Loaded Configuration File this:"C:\MAMP\conf\php7.0.13\php.ini" and not one of the two.
If you are seeing timeouts, you can increase max_execution_time and max_input_time.
I know this question has been asked before, but I've gone through all previously described options and I'm wondering if I'm missing an option. I'm trying upload a file through Apache/PHP that is greater than 2.000GB in size. Files smaller than that work fine.
The following php.ini variables are set, and I have restarted Apache to make sure they are in effect:
max_input_vars = 10000
post_max_size = 5000M
upload_max_filesize = 5000M
max_file_uploads = 1000
max_execution_time = 600
max_input_time = 600
memory_limit = 10000M
I am using a javascript uploader, with no filesize limits in the script, and a PHP page to receive the uploaded files, also with no limits in the script. When it fails, it only gives this error message in the javascript console in Chrome and IE: Failed to load resource: net::ERR_CONNECTION_RESET. There are file size limit checks in the javascript and PHP pages, but those errors are never displayed... so I'm thinking it is not even getting the chance to check the file size in either place.
In case anyone hits this 2.0GB limit, the fix for me was that PHP 5.4 did not support uploads greater than 2.0GB. This limit was changed in PHP 5.6: http://php.net/ChangeLog-5.php#5.6.0
Upgrading to PHP 7.0 worked for me!
I want to import a database which size is 11 MB. I installed xampp local server. it was set in php.ini to 2M.
I set it to upload_max_filesize=128M and also max_file_uploads=128. After that i used the phpinfo() function, which show me that is set to 128 MB, BUT in phpmyadmin it shows me 8MB and i got this message after import: You probably tried to upload a file that is too large. Please refer to documentation for a workaround for this limit.
YES, I restarted the server many times!
I tried to find and answer from another posts but with no results. Can anyone help me with this ? thx
Also set post max size to desired value.
post_max_size=128M
Click on the MySQL config button (see image below) then click my.ini and change: myisam_sort_buffer_size = 8M to myisam_sort_buffer_size = 1888M.
Increase your M size according to your own then click apply.
The Issue
When uploading files of around 8MB or over, I recieve a 500 Internal Server Error.
All PHP settings in php.ini are correct
maxAllowedContentLength has been set in the web.config
Server Info
As one can probably tell from the maxAllowedContentLength, I am running IIS 7.5, with FastCGI and PHP 5.3.17
Additional Info
I have tried so many different things to get this working but simply cannot find the issue.
However, I have found the following bits of info that may help figure out the root of this problem:
When uploading files (larger ones) using the Media Wiki that I have on the server, I receive the same error, this goes to show that it is not an error in my code.
Most importantly - I managed to upload an 18MB file in the Plesk File Manager, this obviously means that Plesk was able to get around this config issue. I have tried to copy all of the Plesk Control Panel settings over to this domain in IIS but this does not seem to work.
The error is being returned before the script is executed, as I have tried writing exit; at the top to try to get a blank screen, but this is ignored and the 500 error is returned.
I think that the issue lies within the configure command part of the PHP configuration, because when I change the handler mapping of the .php files to use the Plesk php-cgi.exe instead of the usual one, I do not get the 500 Internal Error. Having said that, I cannot leave it on this PHP version as it is Plesk's own exe and there are other configuration issues.
The reason why I think it may be to do with the configure command, is simply because this differs hugely from one phpinfo() to the other.
If you have any ideas or suggestions, please post them. I have tried everything to my knowledge and cannot seem to fix this. If only it was Linux...
Thanks in advance
UPDATE 1
Forgot to add, there are no errors being returned in the PHP error log. As for IIS errors, I do not know where to look
UPDATE 2
This is what I have placed in my web.config file:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
UPDATE 3
With your help, we have managed to get the error displayed by IIS. This is what I am receiving:
PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit
of 8388608 bytes in Unknown on line 0
Is that to do with post_max_size?
UPDATE 4
PHP settings as follows (from phpinfo()):
post_max_size = 64M
memory_limit = 128M
max_file_uploads = 20
max_execution_time = 6000
upload_max_filesize = 64M
UPDATE 5
Lastly, just in case anybody can spot any potential issues, Plesk is able to upload large files absolutely fine, so I assumed that their php-cgi.exe was compiled differently. When I read a phpinfo() of their configuration the configure command information was very different:
My configuration:
cscript /nologo configure.js "--enable-snapshot-build"
"--disable-isapi" "--enable-debug-pack" "--without-mssql"
"--without-pdo-mssql" "--without-pi3web"
"--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared"
"--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared"
"--with-mcrypt=static" "--disable-static-analyze"
Plesk's Configuration:
cscript /nologo configure.js "--enable-debug-pack" "--enable-cli"
"--enable-cgi" "--enable-isapi" "--enable-one-shot" "--enable-pdo"
"--enable-intl" "--with-openssl=shared" "--with-pdo-odbc"
"--with-iconv" "--with-xml" "--with-xsl" "--with-mysql"
"--with-mysqlnd" "--with-mysqli" "--with-pdo-sqlite"
"--with-pdo-mysql" "--with-curl=shared" "--enable-mbstring"
"--enable-mbregex" "--with-imap=shared" "--enable-sockets"
"--enable-shmop" "--enable-soap"
UPDATE (ANSWER)
This is extremely weird as the phpinfo() info is saying one thing, but it is obviously being ignored, not sure why.
If I change the post_max_size in Plesk, for that particular domain/sub-domain, then nothing is changed (although it appears to have changed in the phpinfo()). However, if I actually change the post_max_value in the php.ini then this fixes the issue.
The reason why this is not a good way to fix this, is simply because when Plesk updates, the php.ini is overwritten as PHP is updated and resultantly the changes made to the php.ini are lost. Which means that everytime that Plesk updates I will need to make changes tot he php.ini. This is why Plesk offers the ability to change PHP settings without making changes to the php.ini.
Can anybody think of why PHP is ignoring the local value and reverting to the value in the php.ini, even though the php.ini states that the local value is different?
If you look at the source code of PHP, you can see on the file php-5.4.8-src\main\rfc1867.c line 706-709 this:
if (SG(post_max_size) > 0 && SG(request_info).content_length > SG(post_max_size)) {
sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size));
return;
}
Same is there also in file php-5.4.8-src\main\SAPI.c.
So, the message PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 is about post_max_size setting. You have confirmed from using phpinfo() that you have this setting configured correctly, but it seems to be using the default value of 8M anyway.
As to why, see this thread:
As it turns out, on Windows, you can only set ini directives that are
marked PHP_INI_USER per directory. Unfortunately,
upload_max_filesize and post_max_size are both PHP_INI_PERDIR.
From the PHP docs at
http://php.net/manual/en/configuration.changes.php
The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values
under the key should have the name of the PHP configuration directive
and the string value. PHP constants in the values are not parsed.
However, only configuration values changeable in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
So even though Plesk has an interface to change those directives, and
even though phpinfo() picks up on them, they do nothing to change
the actual max upload sizes. Plesk should not allow you to change
those on Windows, and phpinfo() should not report the change, but
what can you do.
So, it's post_max_size, and it needs to be set on php.ini. Plesk setting simply will not work, even though phpinfo says otherwise. I also opened a bug entry on phpinfo behaviour as there didn't seem to be an entry for it.
This is a fairly common error and is due to the fact that the size of data being uploaded does not match file size: even if you POST max size is not exceeded by the file size, it could be by the uploaded data size.
See this page in the PHP manual.
; Maximum size of POST data that PHP will accept.
post_max_size = 8M
Another source of troubles (for VERY large texts) is UTF8 encoding. You might find yourself with a "six megabytes" TEXTAREA that is actually 6 mega*characters*, and with international codepoints it might run to, say, 8.2 megabytes. Thus you get an apparently contradictory situation of "six megabytes data exceed the configured 8 megabytes limit".
Update
You report two apparently contradictory facts:
PHP settings as follows (from phpinfo()):
post_max_size = 64M
and
PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit of 8388608 bytes
It is clear from the PHPINFO that the limit for POST is 64M. Yet the error says that the limit is 8M (the default). So it seems to me that your code is talking to two different PHP implementations (Two different virtual hosts? A CGI version and a non-CGI version in the same host? Two different machines?)
IIS will re-use the FastCGI processes. You will need to kill off any old processes to get php.ini to reload.
Edit the FastCGI module and edit 'monitor changes to file' and select the php.ini file. This will force the child processes to restart whenever you save an edit.
You could turn the limits to -1, that way, you won't ever have troubles about the size of the files.
It is probably no the best solution as you are basically saying "if I don't see it, it doesn't exist", but believe, it's really reliable and will always work.
I have a Debian Squeeze install on an Amazon EC2 instance running Apache2, and PHP 5.3.3-7. I would like it to be able to accept uploads from a standard point-and-shoot camera (about 5 MB). Accordingly, I've edited php.ini in /etc/php5/apache2/ to allow for up to 18MB uploads, and I've upped the time PHP will allow to work on a script.
Despite restarting Apache and even the machine itself, it absolutely refuses to upload any file larger than 2 MB. Is this an EC2 problem or is it still a PHP issue. I'm fairly sure I've ironed out all possibility of it being PHP, but I've been staring at the same 4 lines of code for the last week and searching like a mad person for what this could possibly be.
/etc/php5/apache2/php.ini:
max_execution_time = 120
...
max_input_time = 120
...
upload_max_filesize = 18M
...
post_max_size = 18M
I have double checked just now with phpinfo(), these settings are in effect, but it still does not work.
Check settings upload_max_filesize and post_max_size in your php.ini file
The problem is likely to be Sohusin. The default packages from APT on debian has Sohusin built in.
This also affects your upload size limit. Take a look at this link for a fix and an explanation:
http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/
don't know if that will be of any help on your setup?
In Apache:
TimeOut
Amount of time the server will wait for certain events before failing a request
LimitRequestBody
Restricts the total size of the HTTP request body sent from the client
Also on some server setups you cant change php.inp via scipts
try this
max_execution_time = 120
max_input_time = 120
upload_max_filesize = 40M
post_max_size = 40M
Save then run
sudo service apache2 restart