views:

150

answers:

1

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/
+2  A: 

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.

Rob Wilkerson
Was writing to the My Documents folder for sonme reason. So apache didn't have write permissions there. Solved.
chustar