资源简介
uploadify上传插件完整Demo,项目开发中被uploadify坑了一把,一怒之下写了前后台完整的示例,旨在彻底解决uploadify的问题!
代码片段和文件信息
package com.gsww.open.controller;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadbase;
import org.apache.commons.fileupload.ProgressListener;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import com.gsww.open.common.SpringContextHolder;
import com.gsww.open.entity.sys.SysUserSession;
import com.gsww.open.entity.upload.ShFileData;
import com.gsww.open.service.upload.ShFileDataService;
import com.gsww.open.util.StringHelper;
import com.gsww.open.util.TimeHelper;
public class FileUploadServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 8382832509729035231L;
private ShFileDataService shFileDataService = SpringContextHolder.getBean(“shFileDataService“);
/**
* Constructor of the object.
*/
public FileUploadServlet() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doPost(requestresponse);
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
String fileSize = ““;
// 得到上传文件的保存目录,将上传的文件存放于WEB-INF目录下,不允许外界直接访问,保证上传文件的安全
// E:/upload/data
String savePath =
this.getServletContext().getRealPath(“/WEB-INF/upload“);
// 上传时生成的临时文件保存目录
String tempPath =
this.getServletContext().getRealPath(“/WEB-INF/temp“);
File tmpFile = new File(tempPath);
if (!tmpFile.exists()) {
// 创建临时目录
tmpFile.mkdir();
}
// 消息提示
String message = ““;
try {
//
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-27 17:26 uploadify两个版本\
文件 298 2017-11-27 17:05 uploadify两个版本\crossdomain.xm
文件 9590 2017-11-27 17:25 uploadify两个版本\FileUploadServlet.java
文件 85367 2017-11-27 16:52 uploadify两个版本\uploadify_flash.zip
文件 41339 2017-11-27 17:23 uploadify两个版本\uploadify_html5.zip
文件 359 2017-11-27 17:27 uploadify两个版本\说明.txt
评论
共有 条评论