Is there a possibility to pass image file in one function with dataString?
I've got something like this:
$.ajax({
type: "POST",
url: "../insert.php",
data: dataString,
success: function(response){
console.log(response);
}
});
and everything works fine. Except the image is not send to php, only the name - thats pretty obvious. But how to achieve that?
Check this link: How to send image to PHP file using Ajax?
The accepted answer should send all inputs (string and file).
To add extra inputs, you can try:
var extraInput = document.createElement('input');
extraInput.type = 'text';
extraInput.name = 'name';
extraInput.value = '...';
formData.appendChild(extraInput);