$_FILES [var]['size'] returns 0 for small (30KB) file - why?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leslie WebsiteS
    New Member
    • Apr 2011
    • 2

    $_FILES [var]['size'] returns 0 for small (30KB) file - why?

    I've got a php form handler which takes data from an html page and creates and sends an email with one or more attachments.
    I wanted to be smart and make sure a file had a size GREATER THAN 0. So I set
    $attachment1_si ze = $_FILES['attachment1']['size'];
    if ($attachment1_s ize > 0) {
    And my 30KB file size comes up 0.
    And the error codes showed no error.
    When I took out the test for size and assumed (oh, bad) the file had a size >0, the file attached to the email perfectly.
    My question is this: why, for a SMALL file, am I getting a 0 size?
    The php config upload_max_file size is 2M. The MAX_FILE_SIZE on the html form is 1000000.
    Any suggestions? I'd really like to test the file size.
  • dgreenhouse
    Recognized Expert Contributor
    • May 2008
    • 250

    #2
    That's weird... Are you sure you're not making a mistake in the code somewhere? I'm sure you're actually uploading a "non zero" byte file.

    Hmmmmm....

    Comment

    • Leslie WebsiteS
      New Member
      • Apr 2011
      • 2

      #3
      Here's the relevant code

      In trying to debug, I echoed the size to check - sure enough, it was zero.
      When I commented out the line which tests the size (and its closing bracket), everything worked. So the actual size wasn't zero, even if that's what was in the variable.
      Hmm...
      Attached Files

      Comment

      Working...