if($_FILES['files']['name']!=“”) run if files, don't run if no files headache

邮差的信 提交于 2020-01-15 10:45:41

问题


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']))
 {
  //
 }


来源:https://stackoverflow.com/questions/12380612/if-filesfilesname-run-if-files-dont-run-if-no-files-headache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!