SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: File upload size check

  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    File upload size check

    Hey,

    With the following code

    PHP Code:
        if($_FILES['photoname']['size'] >= 2097152) { 
          
    $error_msg 'Combined file size is to large';
        } 
    Whether I upload one file or 3 files that add up to less than 2mb total, the error message comes back that the file size is to large..

    Is the above code wrong?

    Thanks

  2. #2
    From space with love SitePoint Award Recipient SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,269
    Mentioned
    54 Post(s)
    Tagged
    0 Thread(s)
    echo the file size $_FILES['photoname']['size'] it may be that the size of the file as the server sees it is a little larger then you expect. In Windows when you look up the file size there is "file size" and "size on disc". "size on disc" is generally the larger so it's best to go by that
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

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
  •