PHP
jQuery AJAX single file upload [duplicate]
Login To Post Your Comment
1 comments
MD. KHALED
1 year agoAfter hours of searching and looking for answer, finally I made it!!!!! Code is below :))))
HTML:
jQuery:
$(function(){
$('#uploadBTN').on('click', function(){
var fd = new FormData($("#fileinfo"));
//fd.append("CustomField", "This is some extra data");
$.ajax({
url: 'upload.php',
type: 'POST',
data: fd,
success:function(data){
$('#output').html(data);
},
cache: false,
contentType: false,
processData: false
});
});
});
In the upload.php file you can access the data passed with $_FILES['file'].
Thanks everyone for trying to help:)
I took the answer from here (with some changes) MDN