I am working on my PHP code (insert_post.php) and I have two errors:
**Warning: move_uploaded_file(news_images/RaiderX.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\my_cms\admin\insert_post.php on line 106
Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php60F7.tmp' to 'news_images/RaiderX.jpg' in C:\xampp\htdocs\my_cms\admin\insert_post.php on line 106**
Everything is fine and I can see that data (images) is coming through to my mysql database but I cannot understand why there are these two errors.
This is the code:
Untitled Document
if(isset($_POST['submit'])) {
$post_title = $_POST['post_title'];
$post_date = date('m-d-y');
$post_cat = $_POST['cat'];
$post_author = $_POST['post_author'];
$post_keywords = $_POST['post_keywords'];
$post_image = $_FILES['post_image'] ['name'];
$post_image_tmp = $_FILES['post_image']['tmp_name'];
$post_content = $_POST['post_content'];
if($post_title=='' OR $post_cat=='null' OR $post_author=='' OR $post_keywords=='' OR $post_image=='' OR $post_content==''){
echo "";
exit();
}
else {
move_uploaded_file($post_image_tmp,"news_images/$post_image");
$insert_posts = "insert into posts (category_id,post_title,post_date,post_author,post_keywords,post_image,post_content) values ('$post_cat','$post_title','$post_date','$post_author','$post_keywords','$post_image','$post_content')";
$run_posts = mysqli_query($con,$insert_posts);
echo "";
echo "";
}
}
?>
No comments:
Post a Comment