I use 2 file index.js, upload.php try to upload file(img) through ajax and if success append to div uploadfile_show
.
but it doesn\'t work , have few questio
FormData
takes a form element in its constructor not a jQuery object, also as you are using ajax to submit the form you'll have to prevent its default action(i.e. submitting) by calling preventDefault()
$('.btn').click(function(e){
e.preventDefault();
var uf = $('.uploaddiv form');
var fd = new FormData(uf[0]);
$.ajax({
type: "POST",
url: "upload.php",
data: fd,
processData:false,
contentType: false,
success: function(html){
$('.uploadfile_show').append(html);
}
});
});