我遇到了一个非常烦人的错误。在 > 我的脚本结束后。
<html>
<body>
<h1>Upload file to see previous upload!</h1>
<form action="index.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file">
<br>
<input type="submit" name="submit" value="submit">
</form>
<?PHP
if (isset ($_FILES["file"])) {
$allowedExts = array("jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 1048576)
&& in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "Error: Couldn't upload file!";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"], "files/" . $_FILES["file"]["name"]);
}
} else {
echo "Upload a file NAO!";
}
}
?>
</body>
</html>
所以在我的页面上我可以读到:“ 0) { echo "Error: Couldn't upload file!"; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "files/" . $_FILES["file"]["name"]); } } else { echo "welcome!"; } } ?>
”
好吧,你猜怎么着!那不是我的意图......所以如果有人能解释我为什么会发生这种情况,我将不胜感激。