html
<div class="File">添加附件</div><input id="upfile" name="upfile" type="file" multiple="multiple" style="display:none" /> <div class="FileArea"></div>
js
var str = ""; $("#upfile").click(); $("#upfile").on("change", function () { var obj = document.getElementById("upfile"); var length = obj.files.length; for (var i = 0; i < length; i++) { $(".FileArea").html("");; var temp = obj.files[i].name; str += "<div>" + temp + "</div>"; } $(".FileArea").append(str); });
时间: 2025-01-19 22:02:56