📄 upload_b.jsp
字号:
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../../include.jsp"%>
<html>
<head>
<base target="top">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>上传图片</title>
<%
if ( request.getMethod().equalsIgnoreCase("post") )
{
String name = productMgr.uploadImg(request);
String imgPath = "."+ConfigBean.getStringValue("upload_pro_img");
String newImg=null;
String sImg=null;
String tA[] = name.split("/");
String imgFolder = tA[0];
String imgDate = tA[1];
name = tA[2];
out.println("<script>");
if ( name.indexOf(".") > 0)
{
newImg = imgPath+imgFolder+"/"+imgDate+"/"+name.substring(0,name.indexOf("."))+".jpg";
if ( StringUtil.getInt(request,"upload_type")==1 )
{
if ( StringUtil.getString(request,"autoc").equals("true") )
{
sImg = imgPath+imgFolder+"/"+imgDate+"/"+"s_"+name.substring(0,name.indexOf("."))+".jpg";
productMgr.createSImg(imgPath+imgFolder+"/"+imgDate+"/"+name,sImg);
}
if ( StringUtil.getString(request,"autobw").equals("true") )
{
productMgr.createWaterMark(imgPath+imgFolder+"/"+imgDate+"/"+name,imgPath+"watermark.gif",newImg);
}
/**
else
{
productMgr.createWaterMark(imgPath+name,imgPath+"watermark_blank.gif",newImg);
}
**/
}
if ( StringUtil.getString(request,"autosw").equals("true")&&sImg!=null )
{
productMgr.createWaterMark(sImg,imgPath+"watermark.gif",sImg);
}
else if ( StringUtil.getInt(request,"upload_type")==2&&StringUtil.getString(request,"autosw").equals("true") )
{
productMgr.createWaterMark(imgPath+imgFolder+"/"+imgDate+"/"+name,imgPath+"watermark.gif",imgPath+imgFolder+"/"+imgDate+"/"+name);
}
out.println("window.returnValue='"+imgFolder+"|"+imgDate+"|" + name.substring(0,name.indexOf("."))+".jpg'");
out.println("window.close()");
}
else
{
out.println("alert('" + name + "')");
}
out.println("</script>");
}
%>
<script>
function checkF(theForm)
{
if (theForm.file.value=="")
{
alert("请选择图片");
return(false);
}
else if (theForm.file.value.indexOf("jpg")==-1&&theForm.file.value.indexOf("jpeg")==-1)
{
alert("只能上传JPG或JPEG格式图片");
return(false);
}
return(true);
}
function prev(src)
{
var imgObj = new Image();
imgObj.src=src;
document.getElementById("prev_img").innerHTML="<img width='100' height='100' src='"+src+"' id='prev_img'>";
document.getElementById("img_size").innerHTML=imgObj.width +" x "+imgObj.height;
}
</script>
<link href="../comm.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<form action="" method="post" enctype="multipart/form-data" name="form1" onSubmit="return checkF(this)" target="_self">
<tr>
<td width="19%" height="100" align="center">预览</td>
<td width="40%"><span id="prev_img"></span></td>
<td width="41%" align="center" valign="middle">尺寸<br>
<br>
<span id="img_size"></span></td>
</tr>
<tr>
<td colspan="3"> <input name="file" type="file" onChange="prev(this.value)" size="15">
<input name="Submit" type="submit" class="short-button" value=" 上 传 "> </td>
</tr>
</form>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -