@ 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">
आप निश्चित रूप से इस तरह उपयोगकर्ता के कंप्यूटर से किसी भी फाइल अपलोड नहीं कर सकते। वह कहाँ नेतृत्व करेंगे। – kapa
@ बज़मेगाकापा: कृपया यहां देखें [https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest), "उदाहरण: गैर-HTTP सिंक्रोनस अनुरोध" – Randomblue
हां, यह स्थानीय स्तर पर चलने वाली स्क्रिप्ट से प्राप्त करने के लिए काम कर सकता है एक पंक्ति। लेकिन आप दूरस्थ सर्वर पर फ़ाइलों को अपलोड करने के लिए इसका उपयोग नहीं कर सकते हैं। – kapa