当我的脚本尝试将图像放入文件夹时出现此错误。照片应该在 techportal/images/1/image.jpg 中。我需要什么来定义我的目录才能使这项工作正常进行?
move_uploaded_file(): Unable to move '/var/tmp/phpsYW3wW' to '../images/1/profile.jpg' in /home4/saintfiv/public_html/pianotunerpros/techportal/index.php on line 26
当我的脚本尝试将图像放入文件夹时出现此错误。照片应该在 techportal/images/1/image.jpg 中。我需要什么来定义我的目录才能使这项工作正常进行?
move_uploaded_file(): Unable to move '/var/tmp/phpsYW3wW' to '../images/1/profile.jpg' in /home4/saintfiv/public_html/pianotunerpros/techportal/index.php on line 26
错误报告脚本路径:
/home4/saintfiv/public_html/pianotunerpros/techportal/index.php
在简单的设置中,“../images/1/profile.jpg”路径并不指向您想要的位置。
尝试使用“images/1/profile.jpg”并确保该目录已创建且可写。
此外,要确定您在哪个目录,请尝试使用 getcwd() 和 chdir() 函数,它们可以在调试中帮助您:
几天前我面临同样的问题我认为这个错误是由于你提供的路径不正确而发生的。你提供的路径就像"../images/1/profile.jpg"你使用的方式不正确"images/1/profile.jpg"。use dirname(__FILE__) give you present location of file并且您提供了从位置到要上传的位置的路径。像:-
"C:\wamp\www\familypark\administer" //location where my upload.php file exits
"C:\wamp\www\familypark\administer\assets\upload\park_images"//location from root where i want to upload my picture
so i used like this and hence it work fine
$path='assets/upload/park_logo/';
move_uploaded_file($_FILES['logo_upload']['tmp_name'],$path.$_FILES['logo_upload']['name']);