I have a site where I am allowing a user to select an image. I want this image to be uploaded to my database. I am using php to upload and using Ajax function to pass the image. However, it looks like the image is not really passing as an image but as a .bin when I open the image from my database. Here is my Ajax function
<script>
function AddItem(){
var name = document.forms["additemform"]["nc_name"].value;
var tag = document.forms["additemform"]["nc_tag"].value;
var description = document.forms["additemform"["nc_description"].value;
var image = document.forms["additemform"]["nc_image"].value;
  var isValid = false;
  $.ajax({           
      type: "POST",  
      url: "/AddNewItem.php",  
      data: { "Item_Name": name, "Item_Tag": tag, "Item_Description": description, "Item_Image": image },
      dataType: "json",
      success: function(resp){
        console.log(resp);
        if(resp.reply == "Success")
        {
            isValid = true;
          form.submit();
        }
        else
        {
        isValid = false;
        }
      },
      error: function(data, status){
        console.log(data, status);
        alert("error")
      }
    }); //end Ajax
    console.log(isValid);
     return isValid;
};
</script>
In my AddNewItem.php files, I am grabbing the image like this:
$itemimage = base64_encode($_POST["Item_Image"]);
after this, I simply upload to database. Uploading is working but it looks like I am uploading in wrong format. What am I doing wrong. I need to make sure it is a jpeg getting uploading but it is uploading in a .bin format.
 
    