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

Crystal ·
更新时间:2024-11-14
· 770 次阅读

找了好久终于找到一个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>

您可能感兴趣的文章:Jsp页面实现文件上传下载类代码JSP上传文件到指定位置实例代码jsp中点击图片弹出文件上传界面及预览功能的实现jsp实现文件上传下载的程序示例AJAX和JSP实现的基于WEB的文件上传的进度控制代码jsp文件上传与下载实例代码jsp+ajax实现无刷新上传文件的方法JSP实现快速上传文件的方法用JSP编写文件上传JSP实用教程之简易文件上传组件的实现方法(附源码)



IE6 文件上传 ie JSP IE8 IE7

需要 登录 后方可回复, 如果你还没有账号请 注册新账号