我正在尝试在多个图像上传中显示图像名称。在单个选择的情况下,它的工作情况但是在多个选择图像名称重复的情况下。请检查我的小提琴。我也试图显示图像路径
答案 0 :(得分:0)
你只需要改变:
工作小提琴:https://jsfiddle.net/1kojL0pk/
var f = $('.trnsupload').prop("files")[0]['name'];
要
var f = $('.trnsupload').prop("files")[i]['name'];
//完整代码:
window.Transfer = function (input) {
if (input.files && input.files[0]) {
$(input.files).each(function (i) { // add index over here
var f = $('.trnsupload').prop("files")[i]['name']; // access file using i-th index
var reader = new FileReader();
reader.readAsDataURL(this);
reader.onload = function (e) {
$("#Viewer").append("<div class='imageContainer'><img onclick='changeIt(this)' class='thumb img-thumbnail' src='" + e.target.result + "'> <span class='MultiFile-title'>" + f + "</span> <span class='loader'><img src='../../Images/ajax-loader.gif' /></span> <span class='closeCover glyphicon glyphicon-remove'></span></div>");
}
});
}
}