* @see WCF.Upload._initFile()
*/
_initFile: function(file) {
- var $li = $('<li class="box48"><span class="icon icon48 icon-spinner" /><div><div><p>'+file.name+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>');
+ var $li = $('<li class="box48"><span class="icon icon48 icon-spinner" /><div><div><p>'+file.name+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>').data('filename', file.name);
this._fileListSelector.append($li);
this._fileListSelector.show();
+ // validate file size
+ if (this._buttonSelector.data('maxSize') < file.size) {
+ // remove progress bar
+ $li.find('progress').remove();
+
+ // upload icon
+ $li.children('.icon-spinner').removeClass('icon-spinner').addClass('icon-ban-circle');
+
+ // error message
+ $li.find('div > div').append($('<small class="innerError">' + WCF.Language.get('wcf.attachment.upload.error.tooLarge') + '</small>'));
+ $li.addClass('uploadFailed');
+ }
+
return $li;
},
var $fd = new FormData();
var $uploadID = this._createUploadMatrix($files);
+ // no more files left, abort
+ if (!this._uploadMatrix[$uploadID].length) {
+ return;
+ }
+
+ var $validFilenames = [ ];
+ for (var $i = 0, $length = this._uploadMatrix[$uploadID].length; $i < $length; $i++) {
+ var $li = this._uploadMatrix[$uploadID][$i];
+ if (!$li.hasClass('uploadFailed')) {
+ $validFilenames.push($li.data('filename'));
+ }
+ }
+
for (var $i = 0, $length = $files.length; $i < $length; $i++) {
- $fd.append('__files[]', $files[$i]);
+ if ($validFilenames.indexOf($files[$i].name) !== -1) {
+ $fd.append('__files[]', $files[$i]);
+ }
}
$fd.append('actionName', this._options.action);
var $file = files[$i];
var $li = this._initFile($file);
- $li.data('filename', $file.name);
- this._uploadMatrix[$uploadID].push($li);
+ if (!$li.hasClass('uploadFailed')) {
+ $li.data('filename', $file.name);
+ this._uploadMatrix[$uploadID].push($li);
+ }
}
return $uploadID;