SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is if($_FILES)

    simple question

    what is the meaning and purpose of this:

    if($_FILES)

    thanks, cheers!

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,032
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    It is a way to check if files were uploaded during the request (via <input type="file"> in a form or similar). When files are uploaded, information about those files is stored in the $_FILES variable, which is an array. If no files are uploaded the array is empty and if ($_FILES) would not fire (since an empty array cast to a boolean is false). If files are uploaded the array would contain values and if ($_FILES) would fire (since any non-empty array cast to a boolean is true).

    Better would be (IMHO): if (count($_FILES) > 0) (because I don't like implicit casting)
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Tags for this Thread

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
  •