www.webdeveloper.com
Results 1 to 4 of 4

Thread: Check for $_FILES

  1. #1
    Join Date
    Dec 2011
    Posts
    163

    Check for $_FILES

    I am trying to create a check in my code to see if an image was selected in my form

    PHP Code:
    if(isset($_FILES['image'])) 
    doesn't seem to work, as in it keeps telling me is NOT set even when I select an image to upload. I've heard of using

    PHP Code:
    if($_FILES['image']['name'] != ""
    but don't seem that working either...

    Help please...thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,359
    Did you include enctype="multipart/form-data" in your <form> tag?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Dec 2011
    Posts
    163
    Yes sir.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,359
    How about either echoing or logging what's in $_FILES just to see if you're actually getting anything, and if so, how the array is indexed and such (remember that array keys are case-sensitive, just in case):
    PHP Code:
    echo "<pre>".print_r($_FILES1)."</pre>\n";

    // or:

    error_log('$_FILES:'.PHP_EOL.print_r($_FILES1)); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles