Hi i'm using Jquery Upload plugin. I've got this problem:
when i upload the first file this work fine,a single request is sent.
But if i select a second file and i upload it,two request are sent and not one how i expected, the first with the old file and the second with the new one. how i can avoid this behavior?
here's the code:
html:
<form id="upload" >
Select video to upload:
<input id="fileupload" type="file" name="upl" data-url="php/fileUploader/uploaderVideoHandler.php" >
<input type="submit" value="Upload " name="submit">
javascript:
$(function () {
$('#fileupload').fileupload({
method:'POST',
acceptFileTypes: /(\.|\/)(mp4)$/i,
dataType: 'json',
maxNumberOfFiles: 1,
replaceFileInput:false,
autoUpload:false,
add: function (e, data) {
data.context = $('#upload').submit(
function (e) {
e.preventDefault();
data.submit();
});
},
done: function (e, data) {
data.file
$('#progress .bar').text('Upload finished.');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
});
});
i try to reset data.files with
data.files.pop();
but doesn't work.
Solved: Instead using
<input type="submit" value="Upload " name="submit">
i used a button
<button id="up_btn">upload</button>
and i've changed add function to:
$("#up_btn").off('click').on('click', function () {
e.preventDefault();
data.submit();
return false;
});
After spending few hour on
Jquery File UploadI came to know that you can upload file in this way in order to have syn file upload
you can check the documentation here
Problem found
Solution
HTML
JS
Final Code will be :-