How to upload a file only once with blueimp file upload plugin?
I found the answer myself - It's enough to unbind the click event of the button after upload:
add : function(e, data) {
$("#testUploadButton").on("click", function() {
$('#progress .bar').show();
if ($.browser.msie && parseInt($.browser.version, 10) < 10) {
$('#progress .bar').css({
"background" : "url(images/progressbar.gif) no-repeat",
"width" : "100%"
})
} else {
$('#progress .bar').css({
'background-color' : "#2694E8",
'width' : '0%'
});
}
data.submit();
$("#testUploadButton").off("click")
})
},
I had a similar problem where previously uploaded files were included in the next upload. You can try following solution below:
On Add Function just add "change" event of the file input element like below:
$('#YourFileUploadElementId').change(function(e) {
data.files.splice(0); // Clear All Existing Files
});
Full Example Below:
$('#YourFileUploadElementId').fileupload({
// Some options
add: function (e, data) {
$('#YourFileUploadElementId').change(function(e) {
data.files.splice(0); // Clear All Existing Files
});
},
// Other Events
});
Note: Just change the YourFileUploadElementId to your file upload element id.
Here is the complete example on jsfiddle.net
http://jsfiddle.net/dustapplication/cjodz2ma/5/