tags:

views:

87

answers:

2

Hi

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 ?

+1  A: 

You can do this in .htaccess:

php_value memory_limit 64M
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 600
php_value max_input_time 600

or php.ini (see variables above)

fabrik
The documentation is a little spread out, but `upload_max_filesize`, `post_max_size` and `max_input_time` cannot be set with `ini_set()`. See [Where a configuration setting may be set](http://php.net/manual/en/configuration.changes.modes.php), [File Uploads](http://www.php.net/manual/en/ini.core.php#ini.sect.file-uploads), [Data Handling](http://www.php.net/manual/en/ini.core.php#ini.sect.data-handling) and [Runtime Configuration](http://www.php.net/manual/en/info.configuration.php#info.configuration) for more information.
Mike
Sorry for my incorrect tip, i'll edit my answer. Btw i'll go with .htaccess anyway.
fabrik
+3  A: 

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

Mike
*memory\_limit* does not affect the maximum size of an file upload.
Gumbo
@Gumbo: It affects `post_max_size`. See those documentation here: http://www.php.net/manual/en/ini.core.php#ini.post-max-size I have updated the answer to make this clearer.
Mike
There may also be limits set at the webserver level.
symcbean
I found this really helpful, thanks
Flubba