Form can't upload files that is more than 2 MB in size

Discussion in 'PHP' started by KingCobra, Jun 15, 2009.

  1. #1
    My PHP multiupload/file form can't upload files that is more than 2 MB in size?
    What is the problem?
     
    KingCobra, Jun 15, 2009 IP
  2. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #2
    It could be...

    1. A hidden form field for MAX_FILE_SIZE limiting 2mb file size.
    2. check the php.ini file is set to limit file size of 2mb
    3. A code in php script like

    $_FILES['file']['size'] > 2000000
    PHP:
    limiting the file size
     
    olddocks, Jun 15, 2009 IP
  3. KingCobra

    KingCobra Well-Known Member

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

    I didn't set any MAX_FILE_SIZE
    or, use this code -

    $_FILES['file']['size'] > 2000000
     
    KingCobra, Jun 15, 2009 IP
  4. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #4
    check your php.ini for max_upload_filesize configuration
     
    crivion, Jun 15, 2009 IP
  5. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #5
    why not put a hidden field in the upload form specifying your maximum size?
    if you dont specify this, i believe the default setting is 2mb.

    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    HTML:
     
    olddocks, Jun 15, 2009 IP
  6. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #6
    olddocks,

    It may be a cause that I didn't set hidden field for MAX_FILE_SIZE

    But where I use this name "MAX_FILE_SIZE" in my php code?
     
    KingCobra, Jun 15, 2009 IP
  7. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #7
    thats html code (not php)
     
    olddocks, Jun 15, 2009 IP
  8. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #8
    I found the following line in php.ini on my local server

    
    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 64M
    
    Code (markup):
    But my web pages hosted to another web server for make it online. So how or where can I find the php.ini file ?
     
    KingCobra, Jun 16, 2009 IP
  9. BMR777

    BMR777 Well-Known Member

    Messages:
    145
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    140
    #9
    It could also be a post max size restriction.

    Place the following in a .htaccess file in your public_html folder on your site:

    php_value upload_max_filesize 20M
    php_value post_max_size 20M
    Code (markup):

    Replace 20 with the max file upload size you wish to allow. See if that helps.
     
    BMR777, Jun 16, 2009 IP
  10. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #10
    BMR777,

    There is no .htaccess file im my public_html folder ?
    What can i do now ?
     
    KingCobra, Jun 21, 2009 IP
  11. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #11
    no need to use max_file_size in php code. It just limits the form upload file size.
     
    olddocks, Jun 21, 2009 IP
  12. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #12
    In my hosting I can upload more than 2 MB sized file by ftp client
    but, from php form I can't upload more than 2 MB sized file.

    What can I do now?
     
    KingCobra, Jun 24, 2009 IP