使用blueimp上传器,我无法获取文件名。我试试这个代码
on("fileuploaddone", function (e, data) {
$.each(data.files, function (index, file) {
alert(file.name);
});
但它不起作用。尝试完成:",它不起作用,我尝试了很多方法。
我不想重定向到上传的文件名(例如uploaded.jpg)。喜欢" check_file.php?filename =?uploaded.jpg"。但我无法上传文件名。
<script>
/*jslint unparam: true */
/*global window, $ */
$(function () {
'use strict';
// Change this to the location of your server-side upload handler:
var url = window.location.hostname === 'blueimp.github.io' ? '//jquery-file-upload.appspot.com/' : 'jQuery-File-Upload-master/server/php/';
$('#fileupload')
.fileupload({
url: url,
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, 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 + '%'
);
},
done: function (e, data) {
var queryString = 'username=×tamp=';
$.each(data.result, function (index, file) {
queryString += '&file['+index+']='+file.name;
});
window.location.href = 'myNextPage.php?'+queryString
}
// stop: function (e) {
//console.log('Uploads finished');
//window.location = "/result.php"; }
}).on("fileuploaddone", function (e, data) {
$.each(data.files, function (index, file) {
alert(file.name);
});
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled')
;
});
</script>