資源簡介
office2016html后臺模板

代碼片段和文件信息
package?com.baidu.ueditor.um;
import?java.io.*;
import?java.text.SimpleDateFormat;
import?java.util.*;
import?org.apache.commons.fileupload.*;
import?org.apache.commons.fileupload.FileUploadbase.InvalidContentTypeException;
import?org.apache.commons.fileupload.FileUploadbase.SizeLimitExceededException;
import?org.apache.commons.fileupload.util.*;
import?org.apache.commons.fileupload.servlet.*;
import?org.apache.commons.fileupload.FileItemIterator;
import?org.apache.commons.fileupload.disk.DiskFileItemFactory;
import?sun.misc.base64Decoder;
import?javax.servlet.http.HttpServletRequest;
/**
?*?UEditor文件上傳輔助類
?*
?*/
public?class?Uploader?{
//?輸出文件地址
private?String?url?=?““;
//?上傳文件名
private?String?fileName?=?““;
//?狀態(tài)
private?String?state?=?““;
//?文件類型
private?String?type?=?““;
//?原始文件名
private?String?originalName?=?““;
//?文件大小
private?long?size?=?0;
private?HttpServletRequest?request?=?null;
private?String?title?=?““;
//?保存路徑
private?String?savePath?=?“upload“;
//?文件允許格式
private?String[]?allowFiles?=?{?“.rar“?“.doc“?“.docx“?“.zip“?“.pdf““.txt“?“.swf“?“.wmv“?“.gif“?“.png“?“.jpg“?“.jpeg“?“.bmp“?};
//?文件大小限制,單位KB
private?int?maxSize?=?10000;
private?HashMap?errorInfo?=?new?HashMap();
public?Uploader(HttpServletRequest?request)?{
this.request?=?request;
HashMap?tmp?=?this.errorInfo;
tmp.put(“SUCCESS“?“SUCCESS“);?//默認成功
tmp.put(“NOFILE“?“未包含文件上傳域“);
tmp.put(“TYPE“?“不允許的文件格式“);
tmp.put(“SIZE“?“文件大小超出限制“);
tmp.put(“ENTYPE“?“請求類型ENTYPE錯誤“);
tmp.put(“REQUEST“?“上傳請求異常“);
tmp.put(“IO“?“IO異常“);
tmp.put(“DIR“?“目錄創(chuàng)建失敗“);
tmp.put(“UNKNOWN“?“未知錯誤“);
}
public?void?upload()?throws?Exception?{
boolean?isMultipart?=?ServletFileUpload.isMultipartContent(this.request);
if?(!isMultipart)?{
this.state?=?this.errorInfo.get(“NOFILE“);
return;
}
DiskFileItemFactory?dff?=?new?DiskFileItemFactory();
String?savePath?=?this.getFolder(this.savePath);
dff.setRepository(new?File(savePath));
try?{
ServletFileUpload?sfu?=?new?ServletFileUpload(dff);
sfu.setSizeMax(this.maxSize?*?1024);
sfu.setHeaderEncoding(“utf-8“);
FileItemIterator?fii?=?sfu.getItemIterator(this.request);
while?(fii.hasNext())?{
FileItemStream?fis?=?fii.next();
if?(!fis.isFormField())?{
this.originalName?=?fis.getName().substring(fis.getName().lastIndexOf(System.getProperty(“file.separator“))?+?1);
if?(!this.checkFileType(this.originalName))?{
this.state?=?this.errorInfo.get(“TYPE“);
continue;
}
this.fileName?=?this.getName(this.originalName);
this.type?=?this.getFileExt(this.fileName);
this.url?=?savePath?+?“/“?+?this.fileName;
BufferedInputStream?in?=?new?BufferedInputStream(fis.openStream());
File?file?=?new?File(this.getPhysicalPath(this.url));
FileOutputStream?out?=?new?FileOutputStream(?file?);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????733??2018-01-16?10:25??office2016html2018\office2016html2018\web\404.html
?????文件???????2070??2018-01-16?10:25??office2016html2018\office2016html2018\web\add.html
?????文件???????4799??2018-01-16?10:25??office2016html2018\office2016html2018\web\calendar.html
?????文件???????7701??2018-01-16?10:25??office2016html2018\office2016html2018\web\chart.html
?????文件??????19078??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\default.css
?????文件???????1437??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1433??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1433??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1433??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1433??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1433??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1433??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件???????1439??2018-01-16?10:25??office2016html2018\office2016html2018\web\css\st
?????文件??????11703??2018-01-16?10:25??office2016html2018\office2016html2018\web\default.html
?????文件???????6274??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\demo.css
?????文件??????15791??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\demo_fontclass.html
?????文件??????21983??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\demo_symbol.html
?????文件??????16357??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\demo_unicode.html
?????文件??????19428??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\iconfont.css
?????文件??????18444??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\iconfont.eot
?????文件?????127404??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\iconfont.js
?????文件?????116732??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\iconfont.svg
?????文件??????18276??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\iconfont.ttf
?????文件??????12040??2018-01-16?10:25??office2016html2018\office2016html2018\web\font\iconfont.woff
?????文件???????3774??2018-01-16?10:25??office2016html2018\office2016html2018\web\form.html
?????文件??????66622??2018-01-16?10:25??office2016html2018\office2016html2018\web\images\4041.png
?????文件?????????49??2018-01-16?10:25??office2016html2018\office2016html2018\web\images\line.gif
?????文件?????253627??2018-01-16?10:25??office2016html2018\office2016html2018\web\images\login_logo.png
?????文件?????251748??2018-01-16?10:25??office2016html2018\office2016html2018\web\images\logo.png
?????文件?????250043??2018-01-16?10:25??office2016html2018\office2016html2018\web\images\navbg.png
............此處省略150個文件信息
- 上一篇:css+html+js簡單模板
- 下一篇:Fiddler漢化版親測可用
評論
共有 條評論