image upload name not insert in to databse
<p>My html code like this i am having problem with image name image name is not inserted into database table where do i make mistake i do not know in php.ini file_upload is already on still i am facing problem with file upload.. </p>

<pre><code>&lt;form action="category.php" method="post" enctype="multipart/form-data"&gt;
            &lt;input type="hidden" value="{$category_id}" name="category_id"&gt;
              &lt;div class="box-body"&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="exampleInputEmail1"&gt;Category Name&lt;/label&gt;
                  &lt;input type="text" class="form-control" name="category_nm" id="category_nm" placeholder="Enter Category Name" value="{$category_nm}" required&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="cat_img"&gt;File input&lt;/label&gt;
                  &lt;input type="file" id="cat_img" name="cat_img"&gt;
                  &lt;p class="help-block"&gt;Please Select Category Image. (Image Type :- JPG, JPEG, PNG )&lt;/p&gt;
                &lt;/div&gt;
              &lt;/div&gt;&lt;!-- /.box-body --&gt;
              &lt;div class="box-footer"&gt;
                &lt;button type="submit" class="btn btn-primary" name="submit"&gt;Submit&lt;/button&gt;
              &lt;/div&gt;&lt;!-- /.box-footer--&gt;
            &lt;/form&gt;
</code></pre>

<p>My php file upload code is like this        </p>

<pre><code>if(isset($_REQUEST['submit']))
        {
          $category_nm = isset($_POST['category_nm']) ?  $_POST['category_nm'] : '';
          $cat_img     = isset($_POST['cat_img']) ?  $_POST['cat_img'] : '';

          $insertCat = "INSERT INTO category(category_nm,cat_img) 
                                 VALUES('".mysql_real_escape_string ($category_nm)."',
                                          '".mysql_real_escape_string ($cat_img)."')";
        $insertCatRes = mysql_query($insertCat);
        if($insertCatRes)
        {
          $target_dir = "_cat_img/";
          $target_file = $target_dir . basename($_FILES["cat_img"]["name"]);
          $uploadOk = 1;
          $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
          // Check if image file is a actual image or fake image
          if(isset($_POST["submit"])) 
          {
            $check = getimagesize($_FILES["cat_img"]["tmp_name"]);
            if($check !== false) 
            {
              echo "File is an image - " . $check["mime"] . ".";
              $uploadOk = 1;
            } 
            else
            {
              echo "File is not an image.";
              $uploadOk = 0;
            }
          }

          // Check file size
          if ($_FILES["cat_img"]["size"] &gt; 500000)
          {
            echo "Sorry, your file is too large.";
            $uploadOk = 0;
          }
          // Allow certain file formats
          if($imageFileType != "jpg" &amp;&amp; $imageFileType != "png" &amp;&amp; $imageFileType != "jpeg"
            &amp;&amp; $imageFileType != "gif" ) 
          {
            echo "Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.";
            $uploadOk = 0;
          }
            // Check if $uploadOk is set to 0 by an error
          if ($uploadOk == 0) 
          {
            echo "Sorry, your file was not uploaded.";
            // if everything is ok, try to upload file
          }
          else 
          {
            if (move_uploaded_file($_FILES["cat_img"]["tmp_name"], $target_file)) 
            {
              echo "The file ". basename( $_FILES["cat_img"]["name"]). " has been uploaded.";
            }
            else
            {
              echo "Sorry, there was an error uploading your file.";
            }
          }
        }
        else
        {
           //header("Location:category.php");   
        }

      }
</code></pre>