1

Can someone show me some example code on how i would check to see if someone picked a file in the file input field as i only want to display a message if they have.

Cheers,

Chris
  • 1,119
  • 4
  • 17
  • 23
  • 2
    This is well covered in the manual: http://php.net/manual/en/features.file-upload.post-method.php – deceze Dec 07 '10 at 05:06

1 Answers1

1

well if you want it to do it while they were using the form you would need to use javascript you can see it be done here

how to check if a file is selected using javascript?

you want a php solution one way can also bee seen in the same topic

this is for multiply files

foreach($_FILES['item']['size'] as $k=>$v){
    if($v>0)
         //Do something
}

try that

Community
  • 1
  • 1
Breezer
  • 10,410
  • 6
  • 29
  • 50
  • Ohhh one more thing .... If i have multiple file input fields and they are labelled item[] ... How would i redo the above source code to fit that scenario – Chris Dec 07 '10 at 05:23
  • Thats exactly what i was after ... Thanks a bunch Breezer :) – Chris Dec 07 '10 at 05:45