Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change file upload size in linux server

Tags:

php

.htaccess

I have to upload a pdf file with 34MB. My site is in Linux with php. But my site support only 8MB. (I know this from phpinfo). How I increase the size? I heared that we can change it in php.ini through. htaccess. But where I get php.ini? How I change the size?. Does any one give me a solution ?

like image 501
Testadmin Avatar asked Dec 12 '22 21:12

Testadmin


1 Answers

There are multiple settings that can affect the maximum file upload size:

PHP_INI_PERDIR: The following settings can be set in php.ini, .htaccess or httpd.conf:

upload_max_filesize
The maximum size of an uploaded file.

post_max_size
Sets maximum size of post data allowed. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading.

max_input_time
This sets the maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads.

PHP_INI_ALL: The following settings can be set in php.ini, .htaccess, httpd.conf, or with ini_set():

max_execution_time
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. If this limit is too low, your script will terminate before a large file has had time to upload.

memory_limit
This sets the maximum amount of memory in bytes that a script is allowed to allocate. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.

POST upload method
When uploading files via the POST method, you also need to set MAX_FILE_SIZE in your HTML form. See this for more details:

http://www.php.net/manual/en/features.file-upload.post-method.php

Shared hosting
If you are using shared hosting, it is unlikely that you will be able to access the system php.ini file. However, you can set the values in .htaccess or in a per-directory php.ini file. Some shared hosting providers may prevent you from doing this, so you will need to check if this is the case.

.htaccess
Here's a sample .htaccess file:

<IfModule mod_php5.c>
  php_value upload_max_filesize 70M
  php_value post_max_size 80M
  php_value memory_limit 90M
  php_value max_execution_time 240
  php_value max_input_time 240
</IfModule>

Per-directory php.ini
The above settings can also be changed in a per-directory php.ini file. Again, the ability to do this may be restricted by your hosting provder. For more information on this, see here:

http://www.askapache.com/php/custom-phpini-tips-and-tricks.html

Changeable:
For a description of the PHP_INI_* modes, which show where configuration directives may be set, see here:
http://php.net/manual/en/configuration.changes.modes.php

like image 120
Mike Avatar answered Dec 26 '22 09:12

Mike