PHP still won't allow file uploads larger than 2 MB - php

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

Related

Cannot upload file on Apache server

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.

Import file in MAMP(file size exceeded the maximum size permitted)

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.

PHP file upload size limits

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!

Upload form - can't upload / post over 120 Kb

I am building a website with an upload form. It will upload only up to 120 Kb but the browser times out if anything bigger is tried. No error message, the browser just times out.
What I've done so far:
Changed all php.ini settings, .htaccess settings;
Tried different browsers;
Rebuilt the form on another server (hosting company) and it works fine
(removed everything from the upload except the bare basics);
This is where it starts getting weird. It works fine on my friends computer.
I think I've eliminated:
The coding - because it does work;
The server - because it works fine on their computers and on my friends computer
The browser - Well I've used another web-hosting company and the form works fine with them, so I'm guessing it's not a browser problem, or even my internet connection problem or maybe even settings on my computer?
The problem is on my website the form won't work for anything over 120 kb. On the test website on another server it does work. It's only my computer it doesn't work on other peoples computers it does work. Why and why set at 120 kb. Am I missing something?? I'm taking this very personally, it's as if the internet, my computer, or technology just doesn't like me.
EDIT 1:
I've just tried something else. I got another computer and tried it on that to eliminate the possibility it was a problem with the computer. Still doesn't work on a different computer at my house - so I'm thinking my broadband provider? But that doesn't explain why the test website on another server works okay??
Review your settings in:
php.ini
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size=10M
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize=512M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 10
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30
; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; http://php.net/max-input-time
max_input_time = 60
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
It's important after editing php.ini file to restart your httpd server, to re-read php.ini file!
Make sure that you set units correctly. There is no shorthand-bytes
like "MB". You should use "K", "M", "G" for that.
Check this PHP FAQ.
httpd.conf or/and .htaccess
php_value post_max_size 10M
php_value upload_max_filesize 512M
If it really is only your computer, it probably is a browser problem. Have you tried different browsers on your computer? Have you tried disabling all browser plugins and extensions?
If you changed all of your PHP settings in php.ini & you are sure that they are set—perhaps via phpinfo() reflecting your settings—and it still doesn’t work it sounds like it might be a firewall issue where the network itself is limiting content being uploaded.
Unclear what this server is or where you have it setup, but I bet a firewall setting is in play.

PHP stops after exactly 46 seconds

I have seen many topics with a similar question, but not a similar situation, because the php settings do not seem to be the problem.
The current php.ini settings are:
max_execution_time = 600
max_input_time = 600
memory_limit = 512M
post_max_size = 192M
upload_max_filesize = 192M
These settings cannot be overwritten by the local .htaccess
The script
The script is PHP and does the following:
User uploads a movie file (using uploadify).
Once the upload is finished a script uses ffmpeg to convert it in to a lower quality 480p flv file.
The problem
This script has always worked and since the upgrade from php 5.3.9 to 5.3.17 it has stopped working.
The upload part works fine. I have tried it with 1Mb to 190mb files.
Once uploaded the conversion starts and the script always stops at exactly 46 seconds. I have no clue why, but it is always 46 seconds.
The server
The server is a xeon quad-core 16Gb ram and a load average of 0.62 (8 = 100% cpu usage)
I truly have no idea what the problem seems to be. The script worked fine and has not changed. So it must be something to do with the new PHP or perhaps Apache, but I have no clue.
Does anyone have a suggestion regarding what the problem could be?
Check the TimeOut settings for Apache, or add this in the VirtualHost section:
TimeOut 2400
You can also check if it really is a timeout or maybe an other problem (like memory) by making a script that sleeps for 47s:
<?php
sleep(47);
echo "Hi I'm still alive!";
Solution
Thanks to Nin, I found something in my apache error_log and was able to fix it:
Login to WHM > Apache Configuration > Include Editor > Post VirtualHost Include > All
and add
<IfModule mod_fcgid.c>
FcgidProcessLifeTime 8200
FcgidIOTimeout 8200
FcgidConnectTimeout 400
FcgidMaxRequestLen 1000000000
</IfModule>
It seems to be a fcgi problem.

Categories