I added the following to the add function:
$('#filelistholder').empty();
This will clear the file list container every time a new file is added, leaving only the last file.
Hope this helps.
Thus, the full code will look like this:
<script type="text/javascript"> $(function () { $('#fileupload').fileupload({ dataType: "json", url: "/api/upload", limitConcurrentUploads: 1, maxNumberOfFiles: 1, sequentialUploads: true, progressInterval: 100, maxChunkSize: 10000, add: function (e, data) { ///empty fie container every time a new file is added $('#filelistholder').empty(); //add new file $('#filelistholder').removeClass('hide'); data.context = $('<div />').text(data.files[0].name).appendTo('#filelistholder'); $('</div><div class="progress"><div class="bar" style="width:0%"></div></div>').appendTo(data.context); $('#btnUploadAll').click(function () { data.submit(); }); }, done: function (e, data) { data.context.text(data.files[0].name + '... Completed'); $('</div><div class="progress"><div class="bar" style="width:100%"></div></div>').appendTo(data.context); }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#overallbar').css('width', progress + '%'); }, progress: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); data.context.find('.bar').css('width', progress + '%'); } }); }); </script>
Adrian hedley
source share