Can you perhaps tell me why I'm getting this error?
I'm trying to upload a image to a database through php and I'm getting this error the whole time in my picUpload.php
These are the errors I'm getting:
Warning: move_uploaded_file(avatars/beetgejo.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\picUpload.php on line 27
AND
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php206A.tmp' to 'avatars/beetgejo.jpg' in C:\xampp\htdocs\picUpload.php on line 27
and here is my picUpload.php
<?php
include 'connect.php';
include 'header.php';
//This is the directory where images will be saved
$target = "avatars/";
$target = $target . basename( $_FILES['file']['name']);
//This gets all the other information from the form
$pic_location=($_FILES['file']['name']);
//Writes the information to the database
$sql = "INSERT INTO users (pic_location) VALUES ('$pic_location')" ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['file']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
I DON'T KNOW WHAT'S WRONG IN LINE 27! If you can help me solve it, it'll be awesome! Thanks!