欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

jsp 文件上传浏览,支持ie6,ie7,ie8

程序员文章站 2023-11-26 19:51:04
找了好久终于找到一个jsp上能用的…… 分享!! 复制代码 代码如下:<%@ page language="java" contenttype="text/html;...

找了好久终于找到一个jsp上能用的…… 分享!!

复制代码 代码如下:

<%@ page language="java" contenttype="text/html; charset=utf-8"
    pageencoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="../css/common.css" href="css/common.css" type="text/css" />
        <title>管理区域</title>
        <style type="text/css"><!--
#newpreview
{
filter:progid:dximagetransform.microsoft.alphaimageloader(sizingmethod=scale);
}
--></style>
<script type="text/javascript" language="javascript"><!--
var flag=true;
function previewimg(imgfile)
{
//新的预览代码,支持 ie6、ie7,ie8也支持,firefox不支持!!我测试了的……
var newpreview = document.getelementbyid("newpreview");
newpreview.filters.item("dximagetransform.microsoft.alphaimageloader").src = imgfile.value;
if(flag)
{
newpreview.style.width = "100px";
newpreview.style.height = "80px";
}
}
function setimgwh()
{
var newpreview = document.getelementbyid("newpreview");
flag=false;
newpreview.style.width = document.getelementbyid("txtimgwidth").value;;
newpreview.style.height = document.getelementbyid("txtimgheight").value;
}
// --></script>
    </head>
    <body>
        <div id="man_zone">
        <form action="product.do?command=addproduct" method="post" name="upload" enctype="multipart/form-data">
                <table width="100%" border="0" align="center" cellpadding="3"
                    cellspacing="1" class="table_style">

                    <tr>
                        <td class="left_title_2">
                            商品图片:
                        </td>
                        <td><input type="file" name="file" onchange="javascript:previewimg(this);" style="border: 1px #ffffff
solid;background:#efefef" style="border: 1px #ffffff
solid;background:#efefef" /><font color=red>*</font><div id="newpreview"></div></td>
                    </tr>
                    <tr>
                        <td class="left_title_1">
                            <input type="submit" name="submit" value="增加" />
                        </td>
                        <td>
                            <input type="reset" name="reset" value="重置" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </body>
</html>