几周前我有这个html / php代码上传例如.txt文件到我主机服务器上的wwwroot目录中的特定文件夹,它都按预期工作。
作为我对主机服务器的订阅,用完了。我被迫暂时将我的所有html / php文件复制到我的xampp(htdocs)文件夹中。现在,当我尝试通过localhost /上传特定文件夹时,它给出了以下消息:
Upload failed
Here is some more debugging info:Array
(
[uploaded_file] => Array
(
[name] => FREESTYLE.txt
[type] => text/plain
[tmp_name] => /Applications/XAMPP/xamppfiles/temp/php5Bg8XM
[error] => 0
[size] => 34
)
)
我不知道发生了什么,也许xampp配置文件不允许我将文件上传到xampp中的任何文件夹?
我用来上传文件的代码如下:
HTML:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body{
background-image: url("images/bg.jpg");
background-color: #844903;
}
.logo{
position: absolute;
top: 40px;
right: 850px;
}
h1{
position: absolute;
top: 200px;
right: 820px;
color: #a86b00;
}
</style>
<title></title>
</head>
<body>
<div class="logo"><img src="images/logo.jpg" alt="logo"></div>
<h1>Please Upload Your Notes:</h1>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="512000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</body>
</html>
PHP:
<?php
$uploaddir = '/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo "<p>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}
echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
有人知道发生了什么事吗?
谢谢你的时间。
-M