如何获取input框type=file选中的文件对象(FileReader)

      $("input[type='file']").change(function() {
        var file = this.files[0];
        if (window.FileReader) {
          var reader = new FileReader();
          reader.readAsDataURL(file);
          //监听文件读取结束后事件    
          reader.onloadend = function(e) {
            console.log(e.target.result+"路径")
            $(".img").attr("src", e.target.result); //e.target.result就是最后的路径地址
          };
        }
      });

文章来自 https://blog.csdn.net/qq_33769914/article/details/54705820
参考 https://blog.csdn.net/qq_30100043/article/details/76408915

原文地址:https://www.cnblogs.com/hyx626/p/10210643.html