资源简介
ueditor.rar
代码片段和文件信息
package ueditor;
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 = ““;
// 状态
private String state = ““;
// 文件类型
private String type = ““;
// 原始文件名
private String originalName = ““;
// 文件大小
private String size = ““;
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“ “目录创建失败“);
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());
FileOutputStream out = new FileOutputStream(new File(this.getPhysicalPath(this.url)));
BufferedOutputStream output = new Bu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1742 2013-01-29 15:23 ueditor\build\build_editor_css_all.js
文件 1749 2013-01-29 15:23 ueditor\build\build_editor_js_all.js
文件 871260 2013-01-29 15:23 ueditor\build\js.jar
文件 306 2013-01-29 15:23 ueditor\build\merge.bat
文件 852834 2013-01-29 15:23 ueditor\build\yuicompressor-2.4.6.jar
文件 12830 2013-01-30 11:05 ueditor\CHANGELOG.TXT
文件 1627 2012-11-29 12:36 ueditor\dialogs\anchor\anchor.html
文件 2602 2012-11-29 12:36 ueditor\dialogs\attachment\attachment.css
文件 6248 2013-01-10 16:54 ueditor\dialogs\attachment\attachment.html
文件 6009 2012-11-29 12:36 ueditor\dialogs\attachment\callbacks.js
文件 923 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_chm.gif
文件 841 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_default.png
文件 1012 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_doc.gif
文件 949 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_exe.gif
文件 986 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_mp3.gif
文件 1001 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_mv.gif
文件 996 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_pdf.gif
文件 1001 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_ppt.gif
文件 1009 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_psd.gif
文件 1007 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_rar.gif
文件 970 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_txt.gif
文件 1005 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeImages\icon_xls.gif
文件 747 2012-11-29 12:36 ueditor\dialogs\attachment\fileTypeMaps.js
文件 1102 2012-11-29 12:36 ueditor\dialogs\background\background.css
文件 2891 2012-11-29 12:36 ueditor\dialogs\background\background.html
文件 11952 2013-01-14 13:17 ueditor\dialogs\background\background.js
文件 1842 2013-01-10 16:54 ueditor\dialogs\emotion\emotion.css
文件 5712 2012-11-29 12:36 ueditor\dialogs\emotion\emotion.html
文件 6487 2013-01-10 16:54 ueditor\dialogs\emotion\emotion.js
文件 43 2012-11-29 12:36 ueditor\dialogs\emotion\images\0.gif
............此处省略325个文件信息
相关资源
- 30160830i6v7.gz
- 20171225TIM3-PWM-螺旋桨调速.rar
- DR.COM自动测试帐号器.rar
- 精通比特币.rar
- ISO11898-3-2006道路车辆—控制器区域网
- FANUC-18I参数说明书.pdf
- AI安全调研报告_v5.docx
- 课程设计.rar100608
- 3750969ZXHNZXA10_F601V4.0.2P7T1_ZLD_UPGRADE.im
- A2Uploader.rar
- esp8266-technical_reference_en.pdf
- SIM800_datasheet.pdf
- 摄像测量学原理与应用研究_2009_于起
- GBT36073-2018数据管理能力成熟度评估模
- GBT23703知识管理.zip
- 51622469glomosim-2.03.rar
- cyxd_1.0.zip
- Snort入侵检测系统源码分析--独孤九贱
- (important)数理方程公式大全.doc
- 灰鸽子黑防版.exe
- 设计代码.zip
- 程序原本.pdf
- 各种包.zip
- 《Linux基础千锤百炼》v2.pdf
- DelphiSource.zip
- re4h2b.pdf
- 最新版XISE寄生虫(无后门版).rar
- 测试中文分词.rar
- SSC最新源码.rar
- pdf(9)
评论
共有 条评论