zoukankan      html  css  js  c++  java
  • html 图片上传预览

    Html5 upload img

    2012年12月27日

    20:36

    <!DOCTYPE HTML>

    <html>

     <head>

     <meta http-equiv="Content-Type" content="text/html; charset=utf-">

     <title>html 图片上传预览</title>

     <script src="jquery/jquery-1.8.2.min.js" type="text/javascript"></script>

     <script type="text/javascript">

      $(function(){

          $("input[type='file']").change(function(evt){

             var files = evt.target.files;

     

    for (var i =0 , f; f = files[i]; i++) {

     if (!f.type.match('image.*')) {

                 continue;

               }

     

               var reader = new FileReader();

     

               reader.onload = (function(theFile) {

                 return function(e) {                               

                  $("#list img").attr("src",e.target.result);  //预览图片的位置                

                 };

               })(f);

     

               reader.readAsDataURL(f);

             }

         });

     })

     

     </script>

     </head>

     <body>

     <form enctype="multipart/form-data" action="" method="post">

       <input type="file" name="imageUpload" />

       <div id="list"><img src=""></div>

     </form>

    </body>

    </html>

  • 相关阅读:
    python的多进程
    sqlalchemy的缓存和刷新
    uuid
    区块链的理解
    列表推导式,两个for循环的例子
    Fiddler 抓包工具总结
    python---webbrowser模块的使用,用非系统默认浏览器打开
    使用jmeter做web接口测试
    selenium2中关于Python的常用函数
    Selenium2+Python自动化学习笔记(第1天)
  • 原文地址:https://www.cnblogs.com/thankyouGod/p/6022232.html
Copyright © 2011-2022 走看看