move_uploaded_file() failed to open stream: no such file or directory(move_uploaded_file() 无法打开流:没有这样的文件或目录)
问题描述
我已经完成了你的标准检查(目录是否在那里,权限设置是否足够宽松),而且我很确定我已经涵盖了你标准的愚蠢的人类技巧.这是失败的代码:
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']);
目录在那里 - 我从 FileZilla 复制了路径.我什至在 FileZilla 和 HostGator 控制面板上的文件管理器中将权限设置为 777.此代码生成两个警告:
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:
留言:move_uploaded_file(/public_html/flashsale/assets/img/products/Tsirloin.jpg)[function.move-uploaded-file]:无法打开流:没有那个文件或目录
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
消息:move_uploaded_file() [function.move-uploaded-file]:无法将/tmp/phpI5GZ3S"移动到'/public_html/flashsale/assets/img/products/Tsirloin.jpg'
Message: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpI5GZ3S' to '/public_html/flashsale/assets/img/products/Tsirloin.jpg'
按照这个顺序.所以,文件正在上传,目录存在并设置为777,我还能缺少什么?
In that order. So, the file is being uploaded, the directory exists and is set to 777, what else could I be missing?
推荐答案
你不需要把完整的目录放到文件中.尝试从您的链接中删除 /public_html/flashsale/ 并查看它是否有效.另外文件不需要777权限,我自己上传文件到755权限的文件夹.
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.
此外,您可以在目标目录中使用 getcwd();.该函数将为您提供移动文件所需的目录.来源
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() 无法打开流:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:move_uploaded_file() 无法打开流:没有这样的文件或目
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
