zoukankan      html  css  js  c++  java
  • 预览待上传的本地图片

    <form name="form5" id="form5" method="post" action="#">
    <input type="file" name="file5" id="file5" onchange="preview5()"/>
    </form>
    <script type="text/javascript">
    function preview5(){
    var x = document.getElementById("file5");
    if(!x || !x.value) return;
    var patn = /\.jpg$|\.jpeg$|\.gif$/i;
    if(patn.test(x.value)){
    var y = document.getElementById("img5");
    if(y){
    y.src = "file://localhost/" + x.value;
    }else{
    var img=document.createElement("img");
    img.setAttribute("src","file://localhost/"+x.value);
    img.setAttribute("width","120");
    img.setAttribute("height","90");
    img.setAttribute("id","img5");
    document.getElementById("form5").appendChild(img);
    }
    }else{
    alert("您选择的似乎不是图像文件。");
    }
    }
    </script>
  • 相关阅读:
    服务器常用端口
    xml处理类
    水印的代码
    Asp.net常用的51个代码(非常实用)
    poj 2453
    MOD
    LIS(最长上升子序列)
    POJ各题算法分类(转)
    poj 1496&1850
    poj 1423
  • 原文地址:https://www.cnblogs.com/bgming/p/247367.html
Copyright © 2011-2022 走看看