zoukankan      html  css  js  c++  java
  • 2013年2月26日星期二本地图片预览

    今天基本上把delphi代码写完,开始看部分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$|\.png$/;

    if(patn.test(x.value)){

    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>

  • 相关阅读:
    UIImageView变灰
    IOS 瀑布流
    IOS9适配 MARK
    MAC PHP MARK
    IOS第三方库 MARK
    IOS聊天对话界面
    UILabel自适应宽度的函数详解
    UIControl的使用
    IOS @2X.png
    自定义UIAlertView
  • 原文地址:https://www.cnblogs.com/doit8791/p/2934278.html
Copyright © 2011-2022 走看看