zoukankan      html  css  js  c++  java
  • js :实现图片上传前,预览客户端图片(兼容IE6和IE7)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        
    <title>无标题页</title>
           
    <script type="text/javascript" src="../js/jquery.js" charset="gb2312"></script>
     
    <script type="text/javascript">
    function preview()   
    {   
        
    var picId = $("#picId").val();   
        alert(picId);
        
    var fileext=picId.substring(picId.lastIndexOf("."),picId.length);   
        fileext
    =fileext.toLowerCase();   
        $(
    "#fileext").val(fileext);   
        
    if ((fileext!='.jpg')&&(fileext!='.gif')&&(fileext!='.jpeg')&&(fileext!='.bmp'))   
        {   
            alert(
    "对不起,系统仅支持标准格式的照片,请您调整格式后重新上传,谢谢 !");   
            $(
    "#picId").focus();   
        }   
        
    else  
        {   
            $(
    "#newPreview").html('');   
            
    var newPreview =$("#newPreview")[0];     
            
    var imgDiv = document.createElement("div");    
            document.body.appendChild(imgDiv);   
            imgDiv.style.width 
    = "180px";    imgDiv.style.height = "140px";   
            imgDiv.style.filter
    ="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)";      
            imgDiv.filters.item(
    "DXImageTransform.Microsoft.AlphaImageLoader").src = picId;   
            newPreview.appendChild(imgDiv);   
        }   

    </script>
    </head>
    <body>
    <input name="uploadFile" type="file" class="input_width" id="picId" maxlength="50" onchange="preview()"/>  
    (推荐上传图片像素大小为180*140)   
    <div id="newPreview"></div>  
    </body>
    </html>
  • 相关阅读:
    Python-Image 基本的图像处理操作
    剪枝
    poj1182(食物链)续
    HLG2035广搜
    HLG2040二叉树遍历已知前中,求后
    先序,中序,后序,已知两者求第三者
    C++中new的解说
    僵尸进程
    HLG2062(make,heap问题)
    make_head,,,pop_head,,,push_head,,,sort_head..
  • 原文地址:https://www.cnblogs.com/Fooo/p/1580375.html
Copyright © 2011-2022 走看看