I keep getting this error when I try to upload an image.
Warning: move_uploaded_file(upload/12fbb74863264bfc30324c64163e5e51.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/a7819363/public_html/login/profile.php on line 60
PHP Error Message
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phptGBJ2h' to 'upload/12fbb74863264bfc30324c64163e5e51.jpg' in /home/a7819363/public_html/login/profile.php on line 60
<?php
include('fig.php');
if($_POST) {
// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
if ($_FILES["file"]["error"] > 0) {
// if there is error in file uploading
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
} else {
// check if file already exit in "images" folder.
if (file_exists("upload/" . $_FILES["file"]["name"])) {
} else {
//move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"])) {
// If file has uploaded successfully, store its name in data base
$query_image = "insert into profile_table";
if(mysql_query($query_image)) {
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
} else {
echo'';
}
}
}
}
}
?>