如何检查文件输入字段是否为空? [英] How to check if the file input field is empty?

查看:83
本文介绍了如何检查文件输入字段是否为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难使用$_FILES

我想检查文件上载字段是否为空,然后应用一个条件,使得如果文件上载为空,则脚本不会尝试上载文件.我该如何执行?

I want to check if file upload field is empty or not then apply a condition such that if file upload is empty then the script doesn't try uploading the file. How do I enforce this?

推荐答案

if($_FILES["file"]["error"] != 0) {
//stands for any kind of errors happen during the uploading
} 

也有

if($_FILES["file"]["error"] == 4) {
//means there is no file uploaded
}

这篇关于如何检查文件输入字段是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆