HTML:
<form id="upload" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file"><br>
<input type="submit" id="upload_button" name="upload_button" value="Upload">
</form>
Javascript/jQuery:
$("#filefont").on("change", function(){
var fileupload = document.getElementById("upload_font");
formdata = new FormData(fileupload);
var xmlreq = new XMLHttpRequest();
xmlreq.open("POST", "uploadfont.php", true);
xmlreq.onreadystatechange = function(event){
if(xmlreq.readyState == 4 && xmlreq.status == 200){
alert(xmlreq.responseText);
}
}
xmlreq.send(formdata);
})
The javascript/jquery I have is something I just found off the internet. I tried lots of approaches but I can't seem to find a working way.
I already have a code in PHP, I just can't get the FILES from AJAX/JQuery.