title: Notice: Undefined index: image
body: <p>i am getting this error Notice: Undefined index: image  . i am trying to upload an image to databse  . I cannot figure out whats going on , everything else uploads except the image, not even the image name is uploaded to database</p>
  
  <p>below is code  the size of the file is only 3kb. the       </p>
  
  <pre><code>echo $max_upload = (int)(ini_get('upload_max_filesize')); 
  
  echo "&lt;pre&gt;" . print_r($_POST, true) . "&lt;/pre&gt;";
  
   echo "&lt;pre&gt;". var_dump($_FILES['image']) . "&lt;/pre&gt;";
  </code></pre>
  
  <p>the print_r displays as</p>
  
  <pre><code> Array
  (
  [title] =&gt; This is a post
  [author] =&gt; Me
  [keywords] =&gt; posting
  [image] =&gt; url.jpg
  [content] =&gt; this is a new post 
  [submit] =&gt; Publish now
  )
  </code></pre>
  
  <p>displays as NULL  the vardump </p>
  
  <p>below is actual code. </p>
  
  <pre><code>  &lt;html&gt;
  
  &lt;head&gt; 
  &lt;title&gt; inserting new posts &lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
  &lt;form method="post" action="insert_post.php" enctype="multipart/form-data/"&gt;
  
  &lt;table width="600" align="centre" border"10"&gt;
  
  &lt;tr&gt;
  &lt;td&gt; &lt;h1&gt; Insert New Post here &lt;/h1&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  
  &lt;td&gt; Post title &lt;td&gt;
  &lt;td&gt; &lt;input type="text" name="title" size="30"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; Post Author&lt;td&gt;
  &lt;td&gt; &lt;input type="text" name="author" size="30"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; Post keywords&lt;td&gt;
  &lt;td&gt; &lt;input type="text" name="keywords" size="30"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; Post image &lt;td&gt;    
  &lt;td&gt; &lt;input type="file" name="image"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
  &lt;td&gt; Post Content &lt;td&gt;
  &lt;td&gt; &lt;textarea name="content" cols="20" rows="20" size="30"&gt; &lt;/textarea&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt; Post title &lt;td&gt;
  &lt;td&gt; &lt;input type="text" name="title" size="30"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
  &lt;td&gt; &lt;input type="submit" name="submit" value="Publish now"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  
  &lt;/form&gt; 
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  &lt;?php
  
  
  include('../includes/connect.php');
  
  if(isset($_POST['submit'])){
  
  
  echo $post_title=$_POST['title'];
  
  echo $post_date=date('d-m-y');
  
  echo $post_author=$_POST['author'];
  
  echo $post_keywords=$_POST['keywords'];
  
  echo $post_content=$_POST['content'];
  
  echo $post_image=$_FILES['image']['name'];
  
  echo $image_tmp=$_FILES['image']['tmp_name'];
  
  
  
  
  if($post_title=='' or $post_keywords=='' or $post_content=='' or $post_author==''){
  
  echo "&lt;script&gt; alert('none of the fields can be empty')&lt;/script&gt;";
  
  exit();
  
  }  else{
  
  move_uploaded_file($image_tmp,"../images/$post_image");
  
      //query is below to insert data 
  
  $insert_query="INSERT into posts
  (post_title,post_date,post_author,post_image,post_keywords,post_content)
   VALUES('$post_title','$post_date','$post_author','$post_image','$post_keywords','$post_content')";
  
  
  
  if(mysqli_query($connect,$insert_query)){
  
  echo " &lt;h1&gt; successfully Posted &lt;/h1&gt; ";
  
  
  } else " h1&gt; Did not work &lt;/h1&gt;";
  
  
  
  
  }
  
  
  
  
  
  
  
  
  } 
  
  
   echo $max_upload = (int)(ini_get('upload_max_filesize')); 
  
  echo "&lt;pre&gt;" . print_r($_POST, true) . "&lt;/pre&gt;";
  
   echo "&lt;pre&gt;". var_dump($_FILES['image']) . "&lt;/pre&gt;";
  </code></pre>
  
  <p>?></p>