【JSP开源代码栏目提醒】:网学会员JSP开源代码为您提供AddPicOk.jsp参考,解决您在AddPicOk.jsp学习中工作中的难题,参考学习。
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="com.stuhouse.qqNews.*"%>
<%@ page import="com.stuhouse.qqNews.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.util.*"%>
<%@ page import="java.text.*"%>
<jsp:useBean id="smartUpload" scope="page" class="com.lyforum.upload.SmartUpload" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="admin.css" type="text/css">
<title>无标题文档</title>
</head>
<style type="text/css">
<!--
body {
background-color:#6699CC;
vertical-align:top
}
td {
color:#FFFFFF;
line-height:20px;
letter-spacing:3px;
font-family:"宋体";
}
.TopHeader{
background-color:#FFCC33;
text-align:center
}
-->
</style>
<script language="javascript">
<!--
-->
</script>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#CCCCCC">
<tr class="TopHeader">
<td width="10%"><a href="AddBoard.jsp">添加产品分类</a></td>
<td width="10%"><a href="AddProductInfo.jsp">产品发布</a></td>
<td width="10%"><a href="EditProductInfo.jsp">修改产品信息</a></td>
<td width="10%"><a href="AddNewsBoard.jsp">添加新闻分类</a></td>
<td width="10%"><a href="PublishNews.jsp">新闻发布</a></td>
<td width="10%"><a href="PublishPhotoNews.jsp">发布图片新闻</a></td>
<td width="10%"><a href="NewsManagement.jsp">新闻管理</a></td>
<td width="10%"><a href="PicManagement.jsp">图片管理</a></td>
<td width="10%"><a href="CheckOrderList.jsp">查看订单</a></td>
<td width="10%"><a href="SeeUserInfo.jsp">查看注册用户</a></td>
</tr>
</table>
<br>
<hr width="95%" color="#CCCCCC" size="1px">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<%
Factory factory = Factory.getInstance();
//NewsConfigFactory newsConfigFactory = factory.getNewsConfigFactory();
PicFactory picFactory = factory.getPicFactory();
Pic pic = factory.getPic();
smartUpload.initialize(pageContext);
smartUpload.upload();
com.lyforum.upload.File uploadFile=null;
int fileCount=smartUpload.getFiles().getCount();
int maxUpload=1000;// size must < 1000K
int uploadFileSize=0;
String uploadFileExt="";
//NewsConfig newsAd=newsConfigFactory.getNewsConfig();
String allowUploadExt="jpg,gif,png,bmp";//newsAd.getAllowUploadExt();
String[] allowUploadExtArray=allowUploadExt.split(",");
//String uploadRealPath="e:/boxue/upload/";
String uploadRealPath="../pic/";//application.getRealPath("../pic/");
String uploadFileName="";
//out.println(fileCount);
while(fileCount--!=0) {
//out.println(fileCount);
uploadFile=smartUpload.getFiles().getFile(fileCount);
// uploadFileName=uploadFile.getFileName();
// out.println(uploadFileName);
if(!uploadFile.isMissing()) {
uploadFileSize=uploadFile.getSize();
uploadFileExt=uploadFile.getFileExt().toLowerCase();
boolean flag=false;
for(int i=0;i<allowUploadExtArray.length;i++) {
if(allowUploadExtArray[i].equals(uploadFileExt))
flag=true;
}
if(uploadFileSize>maxUpload*1000)
throw new Exception("上传图片不得超过 "+maxUpload+" KB!");
else if(uploadFileExt.equals("") || !flag)
throw new Exception("文件的类型不支持上传!支持上传的文件类型有:"+allowUploadExt);
else {
String tempSTR="";
int width=0,
height=0,
border=0,
type=3,
boardID=0;
String alt="",
desc="",
link="",
position="",
valign="";
tempSTR=smartUpload.getRequest().getParameter("width"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
width=Integer.parseInt(tempSTR);
tempSTR=smartUpload.getRequest().getParameter("height"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
height=Integer.parseInt(tempSTR);
tempSTR=smartUpload.getRequest().getParameter("border"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
border=Integer.parseInt(tempSTR);
tempSTR=smartUpload.getRequest().getParameter("type"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
type=Integer.parseInt(tempSTR);
tempSTR=smartUpload.getRequest().getParameter("board"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
boardID=Integer.parseInt(tempSTR);
tempSTR=smartUpload.getRequest().getParameter("desc"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
desc=tempSTR;
tempSTR=smartUpload.getRequest().getParameter("alt"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
alt=tempSTR;
tempSTR=smartUpload.getRequest().getParameter("link"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
link=tempSTR;
tempSTR=smartUpload.getRequest().getParameter("position"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
position=tempSTR;
tempSTR=smartUpload.getRequest().getParameter("valign"+fileCount);
if(tempSTR!=null && !tempSTR.equals(""))
valign=tempSTR;
long currentTime=System.currentTimeMillis();
uploadFileName=uploadFile.getFileName();//currentTime+"_"+fileCount+"."+uploadFileExt;
String picfile=uploadRealPath+uploadFileName;
pic.setPicName(desc);
pic.setWidth(width);
pic.setHeight(height);
pic.setBorder(border);
pic.setType(type);
pic.setBoardID(boardID);
pic.setPublishDate(currentTime);
pic.setAlt(alt);
pic.setLink(link);
pic.setAlign(position);
pic.setValign(valign);
pic.setFileName(uploadFileName);
uploadFile.saveAs(picfile);
if(picFactory.AddPic(pic)==1)
out.println("<th><font size=4 style='font-weight:bold'>"+desc+"图片上传成功!</font></th><br>");
else
out.println("<th><font size=4 color='red' style='font-weight:bold'>"+desc+"图片上传失败!</font></th><br>");
}
}
}
%>
</td>
</tr>
</table>
<br>
<center><a href="AddPic.jsp">我想要继续上传图片</a></center>
</body>
</html>
上一篇:
addpic.jsp
下一篇:
法律专业开题报告范文