在这个问题中,我想在php中上传文件但是我无法上传文件而且我收到了这个“警告:move_uploaded”。 enter image description here 我附加了错误屏幕截图。
This is my **uploadhtml.php** file
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
</form>
</body>
</html>
This is my **upload.php** file
<?php
if(!empty($_FILES['uploaded_file']))
{
$path = "uploads/";
$path = $path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path))
{
echo "The file ". basename( $_FILES['uploaded_file']['name']).
" has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
}
}
?>
答案 0 :(得分:0)
将您的添加到绝对本地路径。
$path = dirname(__FILE__) . "/uploads/";
所以你的最终$路径就像/var/www/html/project/upload/filename
move_uploaded_file()
永远不会创建文件夹,因此您应该自己创建上传文件夹。