如何獲取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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM