📄 upload.jsp
字号:
<%@ page contentType="text/html;charset=ISO8859_1" %>
<%@ page import="com.jivesoftware.util.RandomStrg,com.jdon.picture.*" %>
<html>
<head>
<title>upload Image</title>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="jivejdon.css" type="text/css">
</head>
<SCRIPT language = "Javascript">
function selectpic(image){
if ((image.toLowerCase().indexOf("c:") > -1) ||
(image.toLowerCase().indexOf("d:") > -1) ||
(image.toLowerCase().indexOf("e:") > -1) ||
(image.toLowerCase().indexOf("f:") > -1))
{
alert("tyrryuruyruyu");
return false;
}
if (window.opener.document.icon!=null){
window.opener.document.icon.src=image;
window.opener.document.form1.icon.value=image;
window.close();
}else if(window.opener.document.postForm.body!=null){
imgtext="[img]"+image+"[/img]";
window.opener.document.postForm.body.value += imgtext;
window.close();
}
}
</script>
<body>
<%
String status="";
if (request.getParameter("status")!=null)
status=request.getParameter("status");
if (status.equals("save")){
String icon=request.getParameter(request.getParameter("picname"));
String uploadurl="upload/";
%>
<center><img src='<%=uploadurl+icon%>' border=0 name="icon">
<br>
<br>
<script language="javascript">
function MM_openBrWindow(theURL,features) { //v2.0
window.open(theURL,"adwin",features);
}
</script>
<form>
<input type="button" value="selectpic" onclick="selectpic('<%=uploadurl+icon%>')" >
</form>
</center>
</center>
<%
return;
}
if (request.getParameter("pic")==null)
return;
RandomStrg rstr=new RandomStrg();
rstr.setCharset("a-zA-Z0-9");
rstr.setLength(5);
rstr.generateRandomObject();
String picname=request.getParameter("pic")+rstr.getRandom();
%>
<script>
function cal()
{
var maxwidth=300;
var maxheight=300;
var x;
var y;
try
{
if(document.all.<%=picname%>.value!="")
{
document.all.preview.src=document.all.<%=picname%>.value;
}
if ((document.all.<%=MultipartFormHandle.MAXWIDTHPARAMNAME%>.value!="")
&& (document.all.<%=MultipartFormHandle.MAXHEIGHTPARAMNAME%>.value!=""))
{
maxwidth=document.all.<%=MultipartFormHandle.MAXWIDTHPARAMNAME%>.value;
maxheight=document.all.<%=MultipartFormHandle.MAXHEIGHTPARAMNAME%>.value;
if(document.all.oldwidth.value<5)
{
document.all.oldwidth.value=document.preview.width;
}else{
document.preview.width= document.all.oldwidth.value;
}
if(document.all.oldheight.value<5)
{
document.all.oldheight.value=document.preview.height;
}else{
document.preview.height= document.all.oldheight.value;
}
}
if(document.preview.width >maxwidth)
{
x=document.preview.width;
y=document.preview.height;
nx=maxwidth;
ny=maxwidth*y/x;
document.preview.width=nx;
document.preview.height=ny;
}
if(document.preview.height >maxheight)
{
x=document.preview.width;
y=document.preview.height;
ny=maxheight;
nx=maxheight*x/y;
document.preview.width=nx;
document.preview.height=ny;
}
}
catch(e)
{
}
}
function validate(){
var field=document.form1.<%=picname%>;
if (field.value.toLowerCase().indexOf("http://") > -1){
alert("fewfewfwef");
return false;
}
if ((field.value.toLowerCase().indexOf(".gif") <= -1) &&
(field.value.toLowerCase().indexOf(".jpg") <= -1) &&
(field.value.toLowerCase().indexOf(".png") <= -1))
{
alert("fwefewfewfewfwe");
return false;
}
return true;
}
-->
</script>
<body onmouseover=cal() >
<form name="form1" action="<%=request.getContextPath()%>/multipartformserv" method="post" enctype="multipart/form-data" onSubmit="return validate()">
<input type="hidden" name="<%=MultipartFormHandle.FORWARDNAME%>" value="upload.jsp">
<table align="center">
<tr ><td colspan=2>rerererewrwe</td></tr>
<tr ><td colspan=2>rererer</td></tr>
<tr ><td colspan=2>rerere</td></tr>
<tr><td>efsafs</td><td><input type=file name='<%=picname%>' size=30 class=form ><br></td></tr>
<tr ><td colspan=2>rrerere< <%=MultipartFormHandle.SIZE%>K </td></tr>
<tr><td></td><td>
<input type="hidden" name="picname" value="<%=picname%>">
<%
if ((request.getParameter("maxwidth")!=null) && (request.getParameter("maxheight")!=null))
{
%>
<input type="hidden" name="<%=MultipartFormHandle.MAXWIDTHPARAMNAME%>" size="10" value="<%=request.getParameter("maxwidth")%>" >
<input type="hidden" name="<%=MultipartFormHandle.MAXHEIGHTPARAMNAME%>" size="10" value="<%=request.getParameter("maxheight")%>" >
<%
}else{
%>
<input type="hidden" name="<%=MultipartFormHandle.MAXWIDTHPARAMNAME%>" size="10" value="" >
<input type="hidden" name="<%=MultipartFormHandle.MAXHEIGHTPARAMNAME%>" size="10" value="" >
<input type=button value="submit" class=Button onClick="selectpic(document.form1.<%=picname%>.value)">
<%}%>
<input type=submit value="submit" class=Button ><br>
<input type="hidden" name="status" value="save">
</td></tr>
<tr><td align=center colspan=2>
<img name="preview" src="images/white_pix.gif">
<input type="hidden" name="oldwidth" >
<input type="hidden" name="oldheight" >
</td></tr>
</table>
</form>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -