CakePHP 中文件上传神秘失败
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我没有在目标目录上正确设置权限时,我经常收到此错误。出于说明目的,我假设您正在运行 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
. Thatwww
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.