I implemented form and I need to send Image to PHP function.. but is does not work. Did I implement correct selector for my picture?
var photoAdvertisement = $("#pro-img-4").attr('src');
// get values to an array()
var requestArray = "";
requestArray = {"name" : $("#nameAdvertisement").val(),
"category" : $("#categoryAdvertisement").val(),
"description" : $("#descriptionAdvertisement").val(),
"photoAdvertisement" : $("#pro-img-4").attr('src')};
$.ajax({
url: ajaxurl,
type: "POST",
data: {"action": "addAdvertisement", "formValidation": requestArray},
//dataType: "html",
success: function (data) {
console.log("data: "+data);
}
});
Picture of my HTML class and ID with picture
It returned me long string in similar like that => data:image/jpeg;base64,/9j/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3A . Please, is that correct way ?