move_uploaded_file(uploads / test.txt):无法打开流:无此类文件或目录

时间:2019-01-24 20:06:49

标签: php html

我一直试图将文件上传到Web服务器,但是出现这些错误。 你能帮忙吗?

上传文件

Warning: move_uploaded_file(uploads/test.txt): failed to open stream: No such file or directory in C:\Users\p\Desktop\xampp\htdocs\demo\upload.php on line 21

Warning: move_uploaded_file(): Unable to move 'C:\Users\p\Desktop\xampp\tmp\phpDF79.tmp' to 'uploads/test.txt' in C:\Users\p\Desktop\xampp\htdocs\demo\upload.php on line 21

上传文件时出错,请重试!

这是代码

<!DOCTYPE html>
<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>
<?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 个答案:

没有答案