PHP for cant upload more than 2MB file

Discussion in 'PHP' started by KingCobra, Aug 2, 2009.

  1. #1
    I didn't use a hidden form field for MAX_FILE_SIZE limiting 2mb file size.
    I have no php.ini file im my hosting server

    I have found a blank .htaccess in my public_html dir. So I have putted folling lines inside that file. But after that my site doesn't open & show error.

    php_value upload_max_filesize 20M
    php_value post_max_size 20M
    php_value max_execution_time 200
    php_value max_input_time 200

    PLEASE HELP HOW CAN I upload more than 2mb. Is my .htaccess file ok?
     
    KingCobra, Aug 2, 2009 IP
  2. rldowling03

    rldowling03 Notable Member

    Messages:
    1,763
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    200
    #2
    I believe it is php_flag

    php_flag upload_max_filesize 20M
    php_flag post_max_size 20M
    php_flag max_execution_time 200
    php_flag max_input_time 200

    Try that otherwise you can try using ini_set()

    If not then your host may be blocking it, otherwise contact your host to ask them how to solve it
     
    rldowling03, Aug 2, 2009 IP
  3. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    rldowling03,

    I used your code. but the problem is same. my page shows following error message.

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
     
    KingCobra, Aug 2, 2009 IP
  4. rldowling03

    rldowling03 Notable Member

    Messages:
    1,763
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    200
    #4
    Well then your host is most likely not allowing it or some other error. Contact your host and ask them about it, otherwise try ini_set() in the php file itself and delete those from the .htaccess

    
    ini_set("upload_max_filesize", "20M");
    ini_set("post_max_size", "20M");
    ini_set("max_execution_time", "200");
    ini_set("max_input_time", "200");
    
    PHP:
     
    rldowling03, Aug 2, 2009 IP
  5. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Dear rldowling03 ,

    Thanks for your help.
    Would u please completely tell how can i use ini_set() and where to set, which file.
    I small full example code
     
    KingCobra, Aug 2, 2009 IP
  6. rldowling03

    rldowling03 Notable Member

    Messages:
    1,763
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    200
    #6
    Just put what I wrote in the top of your php file under <?php so

    
    <?php
    ini_set("upload_max_filesize", "20M");
    ini_set("post_max_size", "20M");
    ini_set("max_execution_time", "200");
    ini_set("max_input_time", "200");
    
    PHP:
     
    rldowling03, Aug 2, 2009 IP
  7. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It won't work via ini_set(). By that time, the upload will already be cancelled. Your server first uploads the file, then transfers control to PHP. If it doesn't work via .htaccess (with php_value command) then the only possible way to fix this is via php.ini. Contact your host and switch if they don't let you change it.
     
    premiumscripts, Aug 3, 2009 IP