-1

我该怎么做?这些不起作用:

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";
}
4

3 回答 3

9

尝试

样本 :

<?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

于 2012-04-17T20:17:13.737 回答
1
于 2012-04-17T20:12:39.587 回答
1

您可以使用 is_array($_FILES) 检查它是否包含数组格式的文件信息

于 2012-04-17T20:16:12.243 回答