@pedro.dz мне помог ответ:
$(function () {
'use strict';
// Change this to the location of your server-side upload handler:
var url = 'server/php/';
var filesList=new Array();
$('.fileupload').fileupload({
autoUpload: false,//
url: url,
dataType: 'json',
sequentialUploads: true,
add: function (e, data) {
console.log(data);
$.each(data.files, function (index, file) {
filesList.push(file);
console.log('Added file: ' + file.name);
});
console.log(filesList);
},
send: function (e, data) {
console.log('send:');
console.log(e);
console.log(data);
data.formData = {example: "my data"};
},
done: function (e, data) {
console.log('done:');
console.log(e);
console.log(data);
$.each(data.result.files, function (index, file) {
console.log(file);
$('<p/>').text(file.name).appendTo('#files');
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
},
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
$("#uploadfiles").click(function () {
alert('sending');
$('.fileupload').fileupload('send', {files: filesList});
});
});
Для нескольких загрузок:
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>#1 Select files...</span>
<!-- The file input field used as target for the file upload widget -->
<input class="fileupload" type="file" name="files[]" multiple>
</span>
<br>
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>#2 Select files...</span>
<!-- The file input field used as target for the file upload widget -->
<input class="fileupload" type="file" name="files2[]" multiple>
</span>
<input id="formData" type="text" name="formData" value="21212121212">
<input id="uploadfiles" type="button" value="Send">