View Full Version : failed to open stream:

01-25-2008, 02:24 AM
Hi, I have had a look at the other posts on this topic, but I can't seem to get this action to work for me...

This is the error I get:

Warning: move_uploaded_file(uploads/upload.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/nameofsite/public_html/forms/valuations.php on line 122

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpSkRat9' to 'uploads/upload.jpg' in /home/nameofsite/public_html/forms/valuations.php on line 122

Line 122 reads as:

Line 119 - If (is_uploaded_file($_FILES['some_file']['tmp_name'])) {
Line 120 - $target_path = "uploads/";
Line 121 - $target_path = $target_path . basename( $_FILES['some_file']['name']);
Line 122 - if(move_uploaded_file($_FILES['some_file']['tmp_name'], $target_path)) {
Line 123 - $attachment = true;
Line 124 - } else{
Line 125 - $error .= "There was an error uploading the file, please try again!";

I would really appreciate some help on this. Its driving me crazy!!

01-25-2008, 04:36 AM
Have you made completely sure that the directory exists, and you're using the right path to it? And are you sure the CHMOD permissions are set correctly? Should be 755, 777, or otherwise, depending on your security needs.

01-25-2008, 08:14 AM
Thanks for taking the time to reply! The directory "uploads?" exists in nameofsite/public_html/uploads/ and the permissions have been set to 777. The path that is set on Line 120 - $target_path = "uploads/"; This this correct or should this be $target_path = "home/nameofsite/public_html/uploads/"; ?

01-25-2008, 08:27 AM
Hey thanks JohnDubya... I've sorted it!

01-25-2008, 03:45 PM
Hey thanks JohnDubya... I've sorted it!

No problem! :thumbsup: You might post how you fixed it here, so if anyone has the same or similar problem, they can be helped by your experiences. Good luck!