SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ini_set() and post_max_size

    Hello

    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.

    Thank you

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    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.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you.
    Then how can I modify .htaccess through the PHP code?, just like we modify php.ini using ini_set()

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    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.

  5. #5
    SitePoint Enthusiast webdesignhouston's Avatar
    Join Date
    Dec 2010
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most webhosting providers will allow you to change (some) php settings via .htaccess files. Here is what you need to add:

    Code:
    php_value post_max_size 52428800 # 50MB
    php_value upload_max_filesize 52428800 # 50MB
    php_value max_execution_time 300 # 5 minutes
    After making these changes to .htaccess file, double check using:

    PHP Code:
    <?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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •