CakePHP 中文件上传神秘失败

发布于 2024-09-08 20:55:21 字数 813 浏览 4 评论 0原文

我正在尝试使用 CakePHP 文件上传表单帮助程序将文件上传到我的服务器。
我目前在我的开发计算机 (Mac OSX) 上运行 CakePHP 1.3。
当表单提交时,它在传递给控制器​​的变量中包含其临时名称:/var/tmp/name,然后将其名称作为文件名。
但是,当我尝试将文件重命名到更永久的位置时,它会失败,并且如果我转到该位置,它就不存在。

我收到这些错误消息:

Warning (2): move_uploaded_file(Users/chustar/Documents/IMAG0001.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory [APP/controllers/users_controller.php, line 41]
Warning (2): move_uploaded_file() [function.move-uploaded-file]: Unable to move '/private/var/tmp/php98lzsP' to '/Users/chustar/Documents/IMAG0001.jpg' [APP/controllers/users_controller.php, line 41]
Warning (2): Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/cake/libs/debugger.php:673) [CORE/cake/

I'm trying to upload a file to my server using the CakePHP file upload form helper.
I am currently running CakePHP 1.3 on my development computer (Mac OSX).
When the form submits, it has in the variables that are passed to the controller its temp name: /var/tmp/name and then its name as the name of the file.
However, when I try to rename the file to a more permanent location, it fails, and if I go to the location, it doesn't exist.

I get these error messages:

Warning (2): move_uploaded_file(Users/chustar/Documents/IMAG0001.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory [APP/controllers/users_controller.php, line 41]
Warning (2): move_uploaded_file() [function.move-uploaded-file]: Unable to move '/private/var/tmp/php98lzsP' to '/Users/chustar/Documents/IMAG0001.jpg' [APP/controllers/users_controller.php, line 41]
Warning (2): Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/cake/libs/debugger.php:673) [CORE/cake/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖风昔人 2024-09-15 20:55:21

当我没有在目标目录上正确设置权限时,我经常收到此错误。出于说明目的,我假设您正在运行 Apache Web 服务器,并且它以名为 www 的用户身份运行。该 www 用户必须具有目标目录的写入权限。这与拥有哪些权限无关,而是与网络服务器用户拥有哪些权限有关。

如果您发现这不是问题,更多细节和/或一些代码可能会有所帮助。

I get this error a lot when I don't have permissions set properly on the target directory. For the purposes of illustration, I'm going to assume that you're running an Apache web server and that it's running as a user named www. That www user must have write access to the target directory. It's not about what permissions you have, but what permissions the web server user has.

If you find that not to be the problem, a few more specifics and/or some code may be helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文