Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent large Apache/PHP file uploads from failing?

I recently installed a PHP download portal on one of our servers. Everything is working fine, but users can't upload large files (~ 20 MB).

I set the following settings to extremely large values or unlimited:

memory_limit
upload_max_filesize
post_max_size
memory_limit

Full php.ini here: http://pastebin.com/NrqJvMVM

But it still fails after restarting the server.

Am I missing a setting? Do I have to update any values in the Apache configuration? Could a company firewall somehow interfere with that?

EDIT: I checked phpinfo() and the master configuration still shows the old values. The config file C:\Windows\php.ini however, has the new values. Am I using the wrong config file.

like image 823
xsl Avatar asked Jul 06 '12 11:07

xsl


People also ask

What is the maximum file uploading limit in PHP?

By default, PHP file upload size is set to maximum 2MB file on the server, but you can increase or decrease the maximum size of file upload using the PHP configuration file ( php. ini ), this file can be found in different locations on different Linux distributions.

How do I handle a large file to upload?

Possible solutions: 1) Configure maximum upload file size and memory limits for your server. 2) Upload large files in chunks. 3) Apply resumable file uploads. Chunking is the most commonly used method to avoid errors and increase speed.

How can I upload more than 2 MB in PHP?

To upload files larger than 2 MB, change the default value of the upload_max_filesize parameter in the /etc/php. ini file. Important: M and MB are equivalent expressions for "megabyte." For example, 2M is equal to 2 MB. However, use only M in your configuration file, as MB isn't valid in a configuration file.


1 Answers

You can test the params in a script, too. Perhaps this helps:

  1. max_execution_time = ini_set("max_execution_time", "-1");
  2. post_max_size = ini_set("post_max_size", "200M");
  3. memory_limit = ini_set("memory_limit", "200M");
  4. upload_max_filesize = ini_set("upload_max_filesize", "200M");

In .htaccess:

php_value upload_max_filesize 200M

php_value memory_limit 256M

php_value max_execution_time 18000

Here are nice articles about this topic: http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/ | https://www.dokuwiki.org/faq:uploadsize

Is Suhosin installed on your server or do you use fcgi ;-)?

like image 194
chris Avatar answered Dec 06 '22 11:12

chris