if($_FILES['files']['name']!=“”) r

2019-08-11 03:33发布

问题:

Not having any luck with my other thread with specific code so if I can I'd like to ask how people would go about getting this to work.

I have an page where my client edits details of a property displayed on a property list, say they edit text and don't add any images to this property.

HTML form works fine, I'm just looking at the php.

Example:

If files selected then run this script as an include
If no files selected then exit

Something like this...

if($_FILES['files']['name']!="")
 {
 Do this
 }
  else
{
exit();
}

I'm going mental trying to figure this out so any help or suggestions would be great. I have tried a few variations and variations on top of those variations and nothing seems to work so far.

Cheers

回答1:

Use isset() orempty() constructs. (For more information read PHP doc)

if(!empty($_FILES['files']['name']))
 {
  //
 }