?? uploadfile_do.jsp
字號:
<%@ page language="java" contentType="text/html; charset=gbk" %>
<%@ page import="java.sql.*,com.jspsmart.upload.*"%>
<%@ page import="com.zzx.bean.*,com.zzx.manager.*"%>
<!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>
<head>
<title>文件上傳處理頁面</title>
<link rel="stylesheet" type="text/css" href="../inc/admin.css" />
</head>
<body>
<br></br>
<br></br>
<br></br>
<h3 align="center"> 文件上傳成功!</h3>
<%
// 新建一個SmartUpload對象
SmartUpload su = new SmartUpload();
// 上傳初始化
su.initialize(pageContext);
// 設(shè)定上傳限制
// 1.限制每個上傳文件的最大長度。
// su.setMaxFileSize(10000);
// 2.限制總上傳數(shù)據(jù)的長度。
// su.setTotalMaxFileSize(20000);
// 3.設(shè)定允許上傳的文件(通過擴(kuò)展名限制),僅允許doc,txt文件。
// su.setAllowedFilesList("doc,txt");
// 4.設(shè)定禁止上傳的文件(通過擴(kuò)展名限制),禁止上傳帶有exe,bat,jsp,htm,html擴(kuò)展名的文件和沒有擴(kuò)展名的文件。
// su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// 上傳文件
su.upload();
// 將上傳文件全部保存到指定目錄
//int count = su.save("../../../../upload",);
//out.println(count + "個文件上傳成功!<br>");
// 利用Request對象獲取參數(shù)之值
//out.println("TEST=" + su.getRequest().getParameter("TEST")+ "<BR><BR>");
String filecontent = su.getRequest().getParameter("filecontent");
//out.println("圖片描述:" +filecontent + "<BR><BR>");
// 逐一提取上傳文件信息,同時可保存文件。
com.jspsmart.upload.File file = null;
for (int i = 0; i < su.getFiles().getCount(); i++) {
file = su.getFiles().getFile(i);
// 若文件不存在則繼續(xù)
if (file.isMissing())
continue;
%>
<table align="center">
<tr><td>文件長度</td><td><%=file.getSize()%></td></tr>
<tr><td>文件名</td><td><%=file.getFileName()%></td></tr>
<tr><td>圖片描述:</td><td><%=filecontent%></td></tr>
</table>
<p>
<%
file.saveAs("/upload/files/" + file.getFileName(),su.SAVE_VIRTUAL);
UpFile updown = new UpFile();
updown.setFilename(file.getFileName());
updown.setFilecontent(filecontent);
UpDownOper udoper = new UpDownOper();
try{
udoper.insert(updown);
}catch(Exception e){
out.println("文件上傳失?。?quot;);
}
}
%>
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table align="center">
<tr><th>
<a href="uploadfile.jsp">返回上傳文件管理</a>
</th>
</tr>
</table>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -