gpt4 book ai didi

php - 无法上传面临警告 : move_uploaded_file 的文件

转载 作者:行者123 更新时间:2023-11-30 21:51:18 25 4
gpt4 key购买 nike

在这个问题中,我想在 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!";
}
}

?>

最佳答案

将你的添加到绝对本地路径。

$path = dirname(__FILE__) . "/uploads/";

所以你的最终 $path 将像 /var/www/html/project/upload/filename

并且 move_uploaded_file() 从不创建文件夹,因此您应该自己创建上传文件夹。

关于php - 无法上传面临警告 : move_uploaded_file 的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47156792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com