You can modify the PHP memory limit for your website application using the php.ini file.
By default, PHP has a memory limit of 16MB. You can change this limit using two files – .htaccess and php.ini. It’s a fairly simple 2 step process.
Step 1
First, create a .htaccess file in the folder holding the upload script. This file will tell the webserver to use a custom php.ini file for your PHP application. The file should contain the following line of code:
suPHP_ConfigPath /home/username/folder/
Where “username” is your CPanel username and “folder” is the folder where you will upload your custom php.ini file to.
For example, if you have a folder called “TEST” in your public_html/ where you will house your upload script, then the path above will look like:
suPHP_ConfigPath /home/username/public_html/TEST/
Note that this line of code is all that should be present in your .htaccess file. Be aware – the dot before the filename makes it a “hidden” file, i.e. you won’t see it once it’s uploaded to the server. Be sure to place it into the correct folder in your website file structure.
Step 2
Create a php.ini file to tell the server how to behave when you’re uploading a file. In this instance we’re changing the memory limit, so the directive to specify is:
memory_limit
As with all variables in php.ini, you simply provide the value which you would like it to have.
For example, if you want the limit to be 100MB, it will look like this:
memory_limit = 100M ;
Save the file with these values (there may be other variables here as well e.g. safe_mode and register_globals, upload_max_filesize, post_max_size), and upload it to the folder which houses the script requiring more memory and test.
Note, you can modify a lot of settings using php.ini. The options we list in the Support site are simply the most popular ones, but there are lots more that are available. If you’d like to learn more about how to control php.ini file, please visit http://www.php.net/
