JQuery------获取<input type="file">中的文件内容

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);
    });
原文地址:https://www.cnblogs.com/tianhengblogs/p/5977482.html