SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question $_FILES validation

    Hi yall,

    I have been trying to figure the best way to check if my $_FILES array contains, well... files.

    Code:
    if($_FILES['my_field']['name'][0] != ""){
    This does the job, but is there anything simpler or more articulate? I couldn't get any loving from isset or empty, which I thought was odd, as although the array is 'set' when no files are uploaded I doesn't contain any data ('empty' as it were). my_field is an array in itself so its a multi-dimensional type affair.

    Thanks for looking, any savvy ways of rocking the validation would be appreciated!

    porle.

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if($_FILES["your_field"]["error"] != UPLOAD_ERR_OK
    More info: http://www.php.net/manual/en/feature...ad.post-method
    -- Jelena --


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
  •