發表文章

目前顯示的是 2月 23, 2014的文章

[Javascript] Preview an image after browse the file

Preview an image after browse the file Javascript in Page function readURL ( input ) { if ( input . files && input . files [ 0 ]) { var reader = new FileReader (); reader . onload = function ( e ) { $ ( '#image' ). attr ( 'src' , e . target . result ); } reader . readAsDataURL ( input . files [ 0 ]); } } $ ( "#upload" ). change ( function (){ readURL ( this ); });   HTML in Page: <form id = "form1" runat = "server" > <input type = 'file' id = " upload " /> <img id = " image " src = "#" alt = "your image" /> </form>