Change the maximum upload file size
I have a website hosted on a PC I have no access to. I have an upload form allowing people to upload mp3 files up to 30MB big. My server side script is done in PHP.
Every time I try and upload a file, I receive an error claiming that the file exceeds the maximum size allowed, so I need to increase the size. My research on the web suggested changing the
.htaccess file which I do not have access to, so that won't work. Others suggested that I should add a custom
php.ini file to my root which did not work. Any other suggestions?
You need to set the value of
post_max_size in your php.ini :
; Maximum allowed size for uploaded files. upload_max_filesize = 40M ; Must be greater than or equal to upload_max_filesize post_max_size = 40M
After modifying php.ini file(s), you need to restart your HTTP server to use new configuration.
If you can't change your php.ini, you're out of luck. You cannot change these values at run-time; uploads of file larger than the value specified in php.ini will have failed by the time execution reaches your call to
Read more... Read less...
You can change it via an
.htaccess files are stored in the same directory as your
.php files are. They modify configuration for that folder and all sub-folders. You simply use them by creating an
.htaccess file in the directory of your choice (or modify it if present).
The following should enable you to increase your upload limit (if the server provider allows PHP config changes via
php_value upload_max_filesize 40M php_value post_max_size 42M
I had the same problem and i created a .user.ini file and put it in the directory in which the upload script was located. Than inside that file i set these these two values:
upload_max_filesize = 40M post_max_size = 40M
and it worked great for me!
You can also use ini_set function (only for PHP version below 5.3):
ini_set('post_max_size', '64M'); ini_set('upload_max_filesize', '64M');
Like @acme said, in php 5.3 and above this settings are PHP_INI_PERDIR directives so they can't be set using ini_set. You can use user.ini instead.
To locate the ini file, first run
php -i | grep -i "loaded configuration file"
Then open the file and change
upload_max_filesize = 2M post_max_size = 2M
replacing the 2M with the size you want, for instance 100M.
I've got a blog post about with a little more info too http://www.seanbehan.com/how-to-increase-or-change-the-file-upload-size-in-the-php-ini-file-for-wordpress
I have the same problem in the past .. and i fixed it through
When you make change on php configration through
.htaccess you should put configrations in
IfModule tag, other that the Internal server error will arise.
This is an example, it works fine for me:
<IfModule mod_php5.c> php_value upload_max_filesize 40M php_value post_max_size 40M </IfModule>
And this is php referance if you want to understand more. http://php.net/manual/en/configuration.changes.php