[SOLVED] move_uploaded_file problem...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bg
Forum Contributor
Posts: 157
Joined: Fri Sep 12, 2003 11:01 am

move_uploaded_file problem...

Post by bg »

I had code that worked under windows/apache2/php5, gentoo linux/apache2/php5, now im running it under freebsd 5.3/apache2/php5.

I get the error
Warning: move_uploaded_file(/usr/local/www/xxxxxx/script/temp/galleries/X4zV7eJ1j.zip) [function.move-uploaded-file]: failed to open stream: Permission denied in /usr/local/www/xxxxxx/script/admin/add_gallery.php on line 118

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/php6KQ2pb' to '/usr/local/www/xxxxxx/script/temp/galleries/X4zV7eJ1j.zip' in /usr/local/www/xxxxxx/script/admin/add_gallery.php on line 118
The var/tmp folder is chmodded 777, as well as the destination directory. Ive double checked the destination directory, even hard coded it, and still no luck. Any idea whats going on?
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

is safemode on?
if so, the owner of that directory needs to be the same uid as whatever php runs as.
bg
Forum Contributor
Posts: 157
Joined: Fri Sep 12, 2003 11:01 am

Post by bg »

rehfeld wrote:is safemode on?
if so, the owner of that directory needs to be the same uid as whatever php runs as.
nope, safe mode is off per phpinfo();
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Tough problem...

Have you tried using...

Code: Select all

<?php

exec("mv /file/temp_name /file/file/file/templ_name");

?>
Instead of move_uploaded_file();?
bg
Forum Contributor
Posts: 157
Joined: Fri Sep 12, 2003 11:01 am

Post by bg »

neophyte wrote:Tough problem...

Have you tried using...

Code: Select all

<?php

exec("mv /file/temp_name /file/file/file/templ_name");

?>
Instead of move_uploaded_file();?
doesnt work either, and doesnt produce any output. I'm completely lost :evil:
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Try uploading to usr/local/www/xxxxxx/script/temp/galleries/. Forget var/tmp for now. Also, would you be able to post this code for me to look over.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

can you write to the destination directory from php? try making a dummy file w/ fopen() to see if php can.
bg
Forum Contributor
Posts: 157
Joined: Fri Sep 12, 2003 11:01 am

Post by bg »

chowned the destinaton directory to www:www and it worked. It was chmodded 777, and php isnt running in safe mode, but thats what it took. wierd.
Post Reply