Skip to content

Commit

Permalink
Fixed file upload error handling.
Browse files Browse the repository at this point in the history
Thanks to Daouda Kanoute for the report.
  • Loading branch information
blueimp committed Sep 18, 2013
1 parent 717e85a commit 5d55338
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions basic-plus.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<!--
/*
* jQuery File Upload Plugin Basic Plus Demo 1.3.2
* jQuery File Upload Plugin Basic Plus Demo 1.3.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2013, Sebastian Tschan
Expand Down Expand Up @@ -183,7 +183,7 @@ <h3 class="panel-title">Demo Notes</h3>
if (file.error) {
node
.append('<br>')
.append(file.error);
.append($('<span class="text-danger"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
Expand All @@ -198,15 +198,22 @@ <h3 class="panel-title">Demo Notes</h3>
);
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index])
.wrap(link);
if (file.url) {
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index])
.wrap(link);
} else if (file.error) {
var error = $('<span class="text-danger"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.result.files, function (index, file) {
var error = $('<span/>').text(file.error);
$.each(data.files, function (index, file) {
var error = $('<span class="text-danger"/>').text('File upload failed.');
$(data.context.children()[index])
.append('<br>')
.append(error);
Expand Down

0 comments on commit 5d55338

Please sign in to comment.