我该怎么做?这些不起作用:
if(empty($_FILES)){
echo "there is no file uploaded";
exit;
} else {
echo "there is file";
}
if(sizeof($_FILES)!=0){
echo "there is file";
} else {
echo "there is no file";
}
尝试
样本 :
<?php
if (isset ( $_FILES ['image'] )) {
if ($_FILES ["image"] ["error"] == UPLOAD_ERR_OK) {
echo "File Was Uploaded AND OK";
} else {
echo "File Was Uploaded but BAD";
}
} else {
echo "No File Uploaded";
}
?>
<form method="post" enctype="multipart/form-data">
<label for="file">Filename 1:</label> <input type="file" name="image"
id="file" /> <br /> <input type="submit" name="submit" value="Submit" />
</form>
您可以在此处查看更多示例http://php.net/manual/en/function.move-uploaded-file.php
您可以使用 is_array($_FILES) 检查它是否包含数组格式的文件信息