title: No such file or directory using move_uploaded_file()
body: <p>I am working on my PHP code (insert_post.php) and I have two errors:</p>
  
  <p>**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</p>
  
  <p>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**</p>
  
  <p>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.</p>
  
  <p>This is the code:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  
  &lt;style type="text/css"&gt;
  td, td {
          padding:0px;
          margin:0px;
          }
  
  &lt;/style&gt;
  &lt;script src="//tinymce.cachefly.net/4.1/tinymce.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;tinymce.init({selector:'textarea'});&lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form action="insert_post.php" method="post" enctype="multipart/form-data"&gt;
  
          &lt;table width="800" align="center" border="2"&gt;
          &lt;tr bgcolor="#F47302"&gt;
                  &lt;td colspan="6" align="center"&gt;&lt;h1&gt;Insert New Post&lt;/h1&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
                  &lt;td align="right" bgcolor="F47302"&gt;&lt;strong&gt;Post Title:&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="post_title" size="40"&lt;/td&gt;
          &lt;/tr&gt;
  
           &lt;tr&gt;
                  &lt;td align="right"bgcolor="F47302" &gt;&lt;strong&gt;Post Categories:&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;
                  &lt;select name="cat"&gt;
                          &lt;option value="null"&gt;Select a Category&lt;/option&gt;
             &lt;?php
                          include("../includes/database.php");
  
                          $get_cats = "select * from categories";
  
                          $run_cats = mysqli_query($con, $get_cats);
  
                          while ($cats_row=mysqli_fetch_array($run_cats)) {
  
                                  $cat_id=$cats_row['cat_id'];
                                  $cat_title=$cats_row['cat_title'];
  
                                  echo "&lt;option value='$cat_id'&gt;$cat_title&lt;/option&gt;";
                                  }
                          ?&gt;
                  &lt;/select&gt;
  
              &lt;/td&gt;
          &lt;/tr&gt;
  
           &lt;tr&gt;
                  &lt;td align="right" bgcolor="F47302"&gt;&lt;strong&gt;Post Author:&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="post_author" size="40"&lt;/td&gt;
          &lt;/tr&gt;
           &lt;tr&gt;
                  &lt;td align="right" bgcolor="F47302"&gt;&lt;strong&gt;Post Keywords:&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="post_keywords" size="50"&lt;/td&gt;
          &lt;/tr&gt;
  
           &lt;tr&gt;
                  &lt;td align="right" bgcolor="F47302"&gt;&lt;strong&gt;Post Image:&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="file" name="post_image" size="50"&lt;/td&gt;
          &lt;/tr&gt;
           &lt;tr&gt;
                  &lt;td align="right" bgcolor="F47302"&gt;&lt;strong&gt;Post Content:&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="post_content" rows="15" cols="60"&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
           &lt;tr&gt;
              &lt;td colspan="6" align="center" bgcolor="F47302"&gt;&lt;input type="submit" name="submit" value="Publish Now"&lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php
  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 "&lt;script&gt;alert('Please fill in all the fileds')&lt;/script&gt;";
                  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 "&lt;script&gt;alert('Post Has been Published!')&lt;/script&gt;";
  
                          echo "&lt;script&gt;window.open('index.php?insert_post','_self')&lt;/script&gt;";
                  }
          }
  
  ?&gt;
  </code></pre>