I am trying to change post_max_size using ini_set(), but it is not working. After some research I concluded that this is due the time post_max_size is applied.
So what to do in order to change the post_max_size without having to manually edit php.ini nor .htaccess
My script is an upload form, and it must handle large files, and I only want these settings to be applied on it, not all other scripts.
Not possible, unfortunately. post_max_size (and upload_max_filesize) are used before your script is started, so the only way to set them is in .htaccess or php.ini.
Unless PHP has write permissions for .htaccess (which it shouldn’t), you won’t be able to do this with PHP. You’ll have to download the .htaccess file, edit it in Notepad or something similar and then reupload it.
After making these changes to .htaccess file, double check using:
<?php phpinfo(); ?>
Look at the local values.
PS: This works if PHP runs as an APache module. If your web hosting setup is different, you must ask them about how to do this. AFAIK, it is possible to put (some of) the settings in a php.ini file and upload to the root directory of your website but depends on how PHP and Apache are setup.