Friday, May 4, 2018

php - No such file or directory using move_uploaded_file()

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















































Insert New Post

Post Title:
Post Categories:


Post Author:
Post Keywords:
Post Image:
Post Content:






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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...