PHP Increase Upload File Size Limit Using php.ini

July 22nd, 2012 by laeeq | 2 comments

Sometimes you need to upload large files. But the default file upload size settings restrict you to upload large files. PHP default setting allowed only 2MB file upload size.

So if you want to upload large file, then you need to set the following configuration into your your php.ini file:

memory_limit - This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server.

upload_max_filesize – The maximum size of an uploaded file.

post_max_size – This sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.
There are two methods two fix this problem.

Edit php.ini

php.ini file usually stored in /etc/php.ini or /etc/php.d/cgi/php.ini or /usr/local/etc/php.ini on linux server. On WAMP SERVER, PHP.INI file is stored in wamp/bin/php/php.ini.

  1. memory_limit = 32M
  2. upload_max_filesize = 10M
  3. post_max_size = 20M

OR you can also Edit .htaccess file residing on your root directory. This is useful when you do not have access to php.ini file.

  1. php_value upload_max_filesize 10M
  2. php_value post_max_size 20M
  3. php_value memory_limit 32M

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

 

 

  1. oliviamontielzf
    September 28th, 2012 at 12:17 | #1

    Thanks for the sensible critique. Me and my neighbor were just preparing to do a little research about this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such great information being shared freely out there.

  2. galaxys3.devhub.com
    October 26th, 2012 at 03:10 | #2

    Great goods from you, man. You make it enjoyable and you still care for to keep it wise.
    I can’t wait to read far more from you. This is really a tremendous site.

  1. No trackbacks yet.