使用move_uploaded_file

时间:2017-06-02 05:43:29

标签: php forms file-upload

我正在尝试创建一个表单来将图片上传到我的网站,但我不断收到以下错误:

Warning: move_uploaded_file(../Uploads/c0vraJo.jpg): failed to open stream: No such file or directory in /var/www/html/Includes/resource.inc.php on line 43

Warning: move_uploaded_file(): Unable to move '/tmp/phpDMQ2yr' to '../Uploads/c0vraJo.jpg' in /var/www/html/Includes/resource.inc.php on line 43
object(Resource)#3 (2) { ["_id":"Resource":private]=> string(1) "1" ["_path":"Resource":private]=> string(20) "/Uploads/c0vraJo.jpg" } 

代码:

$targetDir = "../Uploads/";

$targetFile = $targetDir . basename($_FILES['picture']['name']);
$fileType = pathinfo($targetFile, PATHINFO_EXTENSION);

move_uploaded_file($_FILES['picture']['tmp_name'], $targetFile);

我正在运行Ubuntu并且我已将文件夹权限设置为777,所有者是www-data,该组是www-data。

如果我需要提供更多信息并提前致谢,请告诉我

0 个答案:

没有答案