<?php
if (isset($_FILES["file"]["name"])) {
$name = $_FILES['file']['name'];
//$size = $_FILES['file']['size'];
//$type = $_FILES['file']['type'];
//$tmp_name = $_FILES['file']['tmp_name'];
if (isset($name)){
if(!empty($name)){
echo 'OK.';
}
else{
echo 'Please choose a file.';
}
}
}
?>
<html>
<form action="upload.php" method="POST" enctype="multipart/form-data" >
<input type="file" name="file">
<input type = "submit" value="Submit" name="submit">
</form>
</html>
答案 0 :(得分:1)
如果文件不存在,则未设置$_FILES['file']['name']
。
if (isset($name)) {}
永远不会开枪。