Okay so this problem has been solved multiple times but mine is a bit more complicated. The following is my AJAX which takes as input Text fields and image and submits the fields and file path to the database.
$(function () {
$('form#data').off('submit').on('submit',function () {
var formData = new FormData($(this)[0]);
$.ajax({
type:'POST',
url: 'upload.php',
data: formData,
async:false,
cache:false,
contentType: false,
processData: false,
success: function (returndata) {$('#result').html(returndata);}
});
return false;
});
});
Now when I submitted a file it was uploaded normally. Then if I tried submitting a second file, it created multiple copies on the database. And it went on exponentially increasing as I went on uploading further.
So I looked up and saw that bind/ unbind and on/off were two solutions.
This worked for for the second file uploaded, but from the third file onwards the repetition continued.
Please let me know where i am going wrong.
Thanks.