我无法使用 PHP 将文件上传到本地主机。我创建了简单的 html 表单和 php 脚本。但是我收到这些错误消息。
'import.html'
<html>
<body>
<form action="import.php" method="POST" enctype="multipart/form-data">
<p>
<label for="file">Choose import.xml</label><br/>
<input type="file" name="import" id="import" /></p>
<p><input type="submit" name="submit" value="Submit" /></p>
</form>
<body>
</html>
'import.php'
<?php
if ($_FILES["import"]["error"] > 0)
{
echo "Return Code: " . $_FILES["import"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["import"]["name"] . "<br />";
echo "Type: " . $_FILES["import"]["type"] . "<br />";
echo "Size: " . ($_FILES["import"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["import"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["import"]["name"]))
{
echo $_FILES["import"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["import"]["tmp_name"],
"upload/" . $_FILES["import"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["import"]["name"];
}
}
?>
错误信息:
警告:move_uploaded_file(upload/import.xml) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\teecom\admin\import.php on line 20
警告:move_uploaded_file() [function.move-uploaded-file]:无法将 'C:\Windows\Temp\phpD02C.tmp' 移动到 C:\xampp\htdocs\teecom\admin\ 中的 'upload/import.xml'第 20 行的 import.php 存储在:upload/import.xml