Page 1 of 1

I cant upload files to my server

Posted: Fri Feb 12, 2010 5:38 am
by daveshoope
I am building a php site that requires users to fill a form and attach a picture. I tested on my local server and everything worked well, but when I uploaded to my server the following error message was echoed
Warning: move_uploaded_file(../applications/DavidOgunsholavictor.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/ipschool/public_html/education/submit.php on line 60

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuFcnIs' to '../applications/DavidOgunsholavictor.jpg' in /home/ipschool/public_html/education/submit.php on line 60
The line 60 of my code is the last line of this code below

Code: Select all

$uploadDir = "../applications/$othernames$surname";
 
$filePath = $uploadDir . $fileName;
 
$result = move_uploaded_file($tmpName, $filePath);
please I need help with this. Thans for the support on this forum

Re: I cant upload files to my server

Posted: Fri Feb 12, 2010 1:59 pm
by Christopher
The error "Permission denied ... Unable to move '/tmp/phpuFcnIs' to '../applications/DavidOgunsholavictor.jpg'" probably means that the web server does not have write permission to the '../applications' directory. Check to see what user the web server (and therefore PHP) runs as (e.g. 'ps aux') -- and then set permissions on that directory so that it can write to it.

Re: I cant upload files to my server

Posted: Fri Feb 12, 2010 2:26 pm
by McInfo
Also try using the absolute path "/home/ipschool/public_html/applications/DavidOgunsholavictor.jpg".

Forum search: "move_uploaded_file permission denied"

Edit: This post was recovered from search engine cache.

Re: I cant upload files to my server

Posted: Mon Feb 15, 2010 2:48 am
by daveshoope
Thanks so much arborint and McInfo. I can now upload to the directory on the server. Little bugs left though, but I'll try out on that. Not reading from the dir.

Thanks a lot :D