I cant upload files to my server

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
daveshoope
Forum Newbie
Posts: 8
Joined: Thu Aug 06, 2009 10:28 am

I cant upload files to my server

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: I cant upload files to my server

Post 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.
(#10850)
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: I cant upload files to my server

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 5:11 pm, edited 1 time in total.
daveshoope
Forum Newbie
Posts: 8
Joined: Thu Aug 06, 2009 10:28 am

Re: I cant upload files to my server

Post 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
Post Reply