move_uploaded_file()无法打开流:没有这样的文件或目录 [英] move_uploaded_file() failed to open stream: no such file or directory
问题描述
$ b $ pre $ move_uploaded_file($ _ FILES ['image1'] ['tmp_name'],/ public_html / flashsale /assets/img/products/T\".$_FILES['image1']['name']);
目录就在那里 - 我复制了 FileZilla 的路径。我甚至在FileZilla和 HostGator 控制面板的文件管理器中设置了 777 的权限。此代码会生成两个警告:
lockquote
消息:
move_uploaded_file(/public_html/flashsale/assets/img/products/Tsirloin.jpg )
[function.move-uploaded-file]:无法打开流:没有这样的文件或
目录
消息:move_uploaded_file()[ function.move-uploaded-file]:无法
将'/ tmp / phpI5GZ3S'移动到
'/public_html/flashsale/assets/img/products/Tsirloin.jpg'
按此顺序。所以,该文件正在上传,该目录存在,并设置为777,还有什么我可以丢失?
你不需要把完整的目录放到文件中。尝试从您的链接中删除 / public_html / flashsale /
,看看是否会起作用。
另外,这个文件不需要有777的权限,我自己上传文件到755权限的文件夹。
也可以用 getcwd();
在你想要的目录中。该功能将为您提供您需要用于移动文件的目录。 来源
I've done your standard checks (is the directory there, are lax enough permissions set), and I'm pretty sure I've covered your standard stupid human tricks. Here's the code that's failing:
move_uploaded_file($_FILES['image1']['tmp_name'], "/public_html/flashsale/assets/img/products/T".$_FILES['image1']['name']);
The directory is there - I copied the path from FileZilla. I even set the permissions to 777, both in FileZilla and in the file manager on the HostGator control panel. This code generates two warnings:
Message: move_uploaded_file(/public_html/flashsale/assets/img/products/Tsirloin.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory
Message: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpI5GZ3S' to '/public_html/flashsale/assets/img/products/Tsirloin.jpg'
In that order. So, the file is being uploaded, the directory exists and is set to 777, what else could I be missing?
you do not need to put the full directory to the file. try to remove /public_html/flashsale/
from your link and see if that will work.
In addition, the file does not need to have 777 permission, I myself upload files to folders with 755 permissions.
also, you can use getcwd();
in the directory your aiming to. the function will give you the directory that you need to use for moving your file. source
这篇关于move_uploaded_file()无法打开流:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!