开发者

File Upload Failing Mysteriously in CakePHP

开发者 https://www.devze.com 2023-01-06 04:09 出处:网络
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).

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/


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号