Facebook

Wednesday, September 7, 2016

Implement multi file upload using blueimp library

If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -----------HTML ------------- ---------- ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>

<!-----Image preview area------> <div class="row fileThumbnails">
   <div class="small-2 columns preview hide">
      <img src="#" class="preview-img">
      <button class="cancel" id="" name=""><i class="fa fa-times" aria-hidden="true"></i></button>
   </div>

</div>
--- ------------- -----------JAVASCRIPT ----------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})
Drop and Drop Files Here
If you want to do some customization in the interface, behaviour etc., I have an example.
I customised the behaviour as per below requirements.
Requirement:
Interface: 
Create a file selector, 
That can select multiple files, 
On selecting files, start uploading images
Show a single progress bar
Display a thumbnail of files selected with a contol(may be a cancel button) near to thumbnail preview to cancel upload of that image only

Blueimp project: https://blueimp.github.io/jQuery-File-Upload/

------ ------------- -------------HTML ------------- ------------ ------
<div id="mulitplefileuploader">
<div class="ajax-upload-dragdrop text-center">
<div class="columns small-12">Drop and Drop Files Here</div>
<div class="columns small-12 drop-drop-img"><img src="{{dragDropURL}}" /></div>
<div class="columns small-12 medium-6 explicit-small-centered upload-multi-files-button">
<label for="fileupload" class="button-alert button expanded">
<img src="{{ uploadIconURL }}"  /> Upload Files
</label>
<input id="fileupload" type="file" name="files[]" multiple />
</div>
</div>
</div>
--- ------------- -------------JAVASCRIPT ------------- ------------ ---
$(document).ready(function () {
$('#fileupload').fileupload({
// This function is called when a file is added to the queue
add: function (e, data) {

//This area will contain file list and progress 
var reader = new FileReader();
reader.onload = function (e) {
data.context = data.files[0].name;
console.log(e.target);
var imgWrap = $('.fileThumbnails .preview.hide').clone(true);
$(imgWrap).attr('data-file-name', data.files[0].name);
$(imgWrap).removeClass('hide').find('img').attr('src', e.target.result);
$(".fileThumbnails").prepend(imgWrap);
imgWrap.find('.cancel').click(function () {
if (!imgWrap.hasClass('finished')) {
jqXHR.abort();
imgWrap.remove();
}
imgWrap.fadeOut(function () {
imgWrap.remove();
});
});
}
reader.readAsDataURL(data.files[0]);

// Automatically upload the file once it is added to the queue
var jqXHR = data.submit()
.success(function (result, textStatus, jqXHR)
{
//imgWrap.remove();
var data = JSON.parse(result);
//console.log(data);
//console.log(data.fileName);
if ($.trim($("#grid-container").html()) == "") {
$("#main-grid-container").html('<div class="row grid grid-margin" id="grid-container">' + data.html + '</div>');
} else {
var Items = parseInt($("#totalMediaItems").html());
Items += 1;
$("#totalMediaItems").html(Items);
$("#grid-container").prepend(data.html);

$(".item-orders").each(function (index, element) {
$(this).html(index + 1)
});

}
$("[data-file-name='" + data.fileName + "']").remove();
if ($("[data-file-name]").length == 0)
{
$('#progress .ajax-file-upload-progress').css(
'width',
'0%'
).html('');
}
})
.error(function (jqXHR, textStatus, errorThrown) {/* ... */})
.complete(function (result, textStatus, jqXHR) {/*....*/});
},
start: function (e) {
$(".ajax-file-upload-container").removeClass('hide');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .ajax-file-upload-progress').css(
'width',
progress + '%'
).html(progress + '%');
}
});
//Helper function for calculation of progress
function formatFileSize(bytes) {
if (typeof bytes !== 'number') {
return '';
}

if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}

if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
}
})

No comments:

Post a Comment