当我从这个表单上传时,它确实上传了两个文件,但它没有得到第二个文件的名称。请检查Fowling代码并告诉我可以对我做什么更改它上传多个并获取seprate的信息文件。
$(document).ready(function(){
$('.direct-upload').each( function(i) {
var form = $(this);
form.fileupload({
url: form.attr('action'),
type: 'POST',
datatype: 'xml',
add: function (event, data) {
// Message on unLoad.
window.onbeforeunload = function() {
return 'You have unsaved changes.';
};
// Submit
console.log(data);
data.submit();
$('.bar').append('<center>' + data.originalFiles[0].name + '</center>');
},
progress: function(e, data){
var percent = Math.round((data.loaded / data.total) * 100);
$('.bar').css('width', percent + '%');
},
fail: function(e, data) {
// Remove 'unsaved changes' message.
window.onbeforeunload = null;
$('.bar').css('width', '100%').addClass('red');
},
done: function (event, data) {
window.onbeforeunload = null;
// Fill the name field with the file's name.
$('#links').append('<p><a href="https://s3.amazonaws.com/bucket_name/<?php echo $_SESSION['username'] ?>/data/'+data.originalFiles[0].name+'">'+data.originalFiles[0].name+'</a></p>');
}
});
});
});
如果我将data.originalFiles [0]更改为data.originalFiles [1],我只获取第二个文件的数据,并且两次#links div块都附加第二个文件的相同名称。