Friday, 4 May 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...