title: Upload image using ajax mysql php
body: <p>I want to try uploading an image using php and mysql. I'm using a form to send data using ajax.</p>
  
  <p>My Html Code:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="file" name="logo" id="logo" class="styled"&gt;
  &lt;textarea rows="5" cols="5" name="desc" id="desc" class="form-control"&gt;&lt;/textarea&gt;
  &lt;input type="submit" value="Add" id="btnSubmit" class="btn btn-primary"&gt;
  </code></pre>
  
  <p>Ajax Code:</p>
  
  <pre class="lang-js prettyprint-override"><code>var formData = new FormData($("#frm_data")[0]);
  $("#btnSubmit").attr('value', 'Please Wait...');
  $.ajax({
      url: 'submit_job.php',  
      data: formData,
      cache: false,
      contentType:false,
      processData:false,
      type: 'post',
      success: function(response)
  </code></pre>
  
  <p>my php code (<em>submit_job.php</em>):</p>
  
  <pre class="lang-php prettyprint-override"><code>$desc =  mysqli_real_escape_string($con, $_POST['desc']);
  $date = date('Y-m-d H:i:s');
  $target_dir = "jobimg/";
  $target_file = $target_dir . basename($_FILES["logo"]["name"]);
  move_uploaded_file($_FILES["logo"]["tmp_name"], $target_file);
  </code></pre>