KEY: 物件、事件、DataURL
FileReader() : line 4, 物件建構元 F,R 大寫,這是物件建構元(constructor)
f.readAsDataURL()
<input type="file" onchange=...>
這個事件中帶有【檔案名稱】。<head> <script> function loadImg(e){ var f=new FileReader(); f.onload=function(){ img.src=f.result; } f.readAsDataURL(e.files[0]); } </script> </head> <body> <input type="file" onchange="loadImg(this)"> <img id="img"> </body>language </body> </html>