
//上传使用第三方的包:JspSmartUpload,可以在csdn上下载到,需要的话可以联系我patriot074@163.com
<%
@ page language
=
"
java
"
import
=
"
java.util.*
"
pageEncoding
=
"
gb2312
"
%>
<%
request.setCharacterEncoding(
"
gb2312
"
);
//
这句话很重要,否则遇到中文就出错~
%>

<!
DOCTYPE html PUBLIC
"
-//W3C//DTD XHTML 1.0 Transitional//EN
"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"
>
<
html
>
<
head
>
<
meta http
-
equiv
=
"
Content-Type
"
content
=
"
text/html; charset=gb2312
"
/>
<
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。
var newPreview = document.getElementById("newPreview");
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
if(flag)

...{
newPreview.style.width = "240px";
newPreview.style.height = "320px";
}
}

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
>
<
form action
=
"
upload_ok.jsp
"
method
=
post name
=
"
Upload
"
enctype
=
"
multipart/form-data
"
>
请输入附件文件的所在路径
<
FONT color
=
red
>
*
</
FONT
>
为必填项目
<
br
>
<
br
>
<
TABLE width
=
"
317
"
border
=
0
cellPadding
=
0
>
<
TBODY
>
<
TR
>
<
TD align
=
left vAlign
=
center nowrap
>
附件路径:
</
TD
>
<
TD
><
input type
=
"
file
"
name
=
"
file
"
onchange
=
"
javascript:PreviewImg(this);
"
style
=
"
border: 1px #FFFFFF solid;background:#efefef
"
>
<
FONT color
=
red
>*</
FONT
></
TD
>
<
TD
><
div id
=
"
newPreview
"
></
div
></
TD
>
</
TR
>
<
TR
>
<
TD
>
设置图片预览宽度:
<
br
><
input type
=
"
text
"
id
=
"
txtImgWidth
"
></
TD
>
<
TD
>
设置图片预览高度:
<
br
><
input type
=
"
text
"
id
=
"
txtImgHeight
"
></
TD
>
<
TD
><
BR
><
input type
=
"
button
"
ID
=
"
setImg
"
value
=
"
设置
"
onclick
=
setImgWH()
></
TD
>
</
TR
>
<
TR align
=
"
left
"
>
<
TD height
=
60
colspan
=
"
2
"
vAlign
=
center nowrap
>
<
INPUT style
=
"
height:22px
"
name
=
B1 type
=
submit value
=
"
确 定
"
>
<
INPUT style
=
"
height:22px
"
name
=
B2 type
=
reset value
=
"
取 消
"
>
</
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
<
input type
=
"
hidden
"
id
=
"
imgWidth
"
value
=
"
240
"
>
<
input type
=
"
hidden
"
id
=
"
imgHeight
"
value
=
"
320
"
>

</
form
>
</
body
>
</
html
>
































































































































































