SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot iamkoa's Avatar
    Join Date
    Mar 2005
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Make Sure User Submits Files?

    I'm sure this is an easy answer, but I just can't figure it out.

    I'm trying to make sure a user submits (or fills out) two file fields on my form. I know how to check to make sure a user has filled out text fields, but what can be used for file fields?

    This is what I have for the normal text fields:
    PHP Code:
    if(($name != "")&&($description != "")&&($reseller != "")&&($unique != "")&&($category != "")&&($coded != "")&&($color != "")){ 
    But this doesn't work for files:
    PHP Code:
    if (($_FILES['file'] != "")&&($_FILES['photo'] != "")){ 
    Thanks for the help.
    Iamkoa, LLC
    Podlodge - Software, tools, and hacks for the iPod

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to do something like this:

    Say you want to make sure the user uploads a picture, so, you create this:

    <INPUT type="file" size="46" name="Picture">

    and you validate like this:

    if (empty($_FILES["Picture"]["name"])) {
    echo "you MUST upload a picture";
    }

  3. #3
    SitePoint Zealot iamkoa's Avatar
    Join Date
    Mar 2005
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jack... works great.
    Iamkoa, LLC
    Podlodge - Software, tools, and hacks for the iPod


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
  •