public void UPLOADFILED() {
Date dt = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String fileName = sdf.format(dt);
int index = getUploadFileName().lastIndexOf(".");
//得到文件扩展名
String extendName = getUploadFileName().substring(index);
String path = getRootPath()+"up\\";
//String sessionId = getRequest().getSession().getId();
String filename = fileName + extendName;
Json j = uploadFile(filename, path, 200 * 1024 *1024, true);
try {
String json = JSON.toJSONStringWithDateFormat(j,"yyyy-MM-dd");
ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
ServletActionContext.getResponse().getWriter().write(json);
ServletActionContext.getResponse().getWriter().flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//writeJson(json);
}


/*public String uploadFile(String path){
return uploadFile(getUploadFileName(), path, 500 * 1024, false);
}*/

/**
* 上传文件
* @param filename 文件名
* @param path 文件保存路径
* @param maxSize 上传文件的最大大小
* @param overwrite 是否覆盖已存在的文件
* @return
*/
public Json uploadFile(String filename, String path, long maxSize, boolean overwrite){
Json j = new Json();
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
String fileName = filename;
String msg = "文件上传成功!";
if (! overwrite) {
//检查并得到新的保存文件名,防止重名后覆盖已存在的文件
fileName = FileUtils.checkFileName(filename, path);
if (FileUtils.isFileExist(fileName, path)) {
/*FileDownloadUtils.downloadJSON("{success:false, msg:'上传文件名已存在,请改名后重新上传!'}",
getResponse());*/
msg = "上传文件名已存在,请改名后重新上传!";
return null;
}
}
if (upload == null) {
/*FileDownloadUtils.downloadJSON("{success:false, msg:'文件名及路径名有问题,请修改后重新上传!'}",
getResponse());*/
msg = "文件名及路径名有问题,请修改后重新上传!";
return null;
}
try {
if (upload.length()> maxSize) {
/*FileDownloadUtils.downloadJSON("{success:false, msg:'上传文件不能大于" + maxSize +",请修改后重新上传!'}",
getResponse());*/
msg = "上传文件不能大于" + maxSize +",请修改后重新上传!";
return null;
}
FileUtils.uploadForName(fileName, path, upload);
} catch (IOException e) {
e.printStackTrace();
/*FileDownloadUtils.downloadJSON("{success:false, msg:'文件上传失败!'}",
getResponse());*/
msg = "文件上传失败!";
return null;
}
j.setSuccess(true);
j.setMsg(msg);
jsonObject.put("name", fileName);
jsonObject.put("type", FileUtils.converContentType(getUploadContentType()));
jsonObject.put("size", upload.length());
jsonArray.add(jsonObject);
j.setObj(jsonArray);
/*FileDownloadUtils.downloadJSON(
"{success:true, msg:'文件上传成功!', " +
"file: {name:'" + fileName +
"', type:'" + FileUtils.converContentType(getUploadContentType()) +
"', size:" + upload.length() + "}}",
getResponse());*/

//errMessage="文件上传成功!";
//success = true;
return j;
}

easyUI + swfupload 多附件上传功能的更多相关文章

  1. ueditor调用其中的附件上传功能

    ueditor实际上是集成了webuploader, 在做内容发布的时候想既有ueditor又有单独的附件上传按钮,这时再加载一个webuploader就显得过于臃肿了,单独利用ueditor的上传功 ...

  2. Web自动化附件上传

    在进行web界面自动化编写时,可以根据定位元素的方式进行编写,但是如果某一个功能涉及到有附件上传功能,那么该如何解决呢? 继续往下看>>>>> 场景:登录系统后,进行新增 ...

  3. odoo开发笔记 -- 附件上传

    附件上传基本原理实现,可以参考这篇: https://www.cnblogs.com/ljwTiey/p/7348291.html http://blog.csdn.net/wangnan537/ar ...

  4. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码]

    原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码] 文件上传这东西说到底有时候很痛,原来的asp.net服务器 ...

  5. ASP.NET MVC5+EF6+EasyUI 后台管理系统(32)-swfupload多文件上传[附源码]

    系列目录 文件上传这东西说到底有时候很痛,原来的asp.net服务器控件提供了很简单的上传,但是有回传,还没有进度条提示.这次我们演示利用swfupload多文件上传,项目上文件上传是比不可少的,大家 ...

  6. 基于MVC4+EasyUI的Web开发框架形成之旅--附件上传组件uploadify的使用

    大概一年前,我还在用Asp.NET开发一些行业管理系统的时候,就曾经使用这个组件作为文件的上传操作,在随笔<Web开发中的文件上传组件uploadify的使用>中可以看到,Asp.NET中 ...

  7. Spring+SpringMVC+MyBatis+easyUI整合优化篇(七)图片上传功能

    日常啰嗦 前一篇文章<Spring+SpringMVC+MyBatis+easyUI整合优化篇(六)easyUI与富文本编辑器UEditor整合>讲了富文本编辑器UEditor的整合与使用 ...

  8. 基于MVC4+EasyUI的Web开发框架形成之旅(4)--附件上传组件uploadify的使用

    大概一年前,我还在用Asp.NET开发一些行业管理系统的时候,就曾经使用这个组件作为文件的上传操作,在随笔<Web开发中的文件上传组件uploadify的使用>中可以看到,Asp.NET中 ...

  9. EBS开发附件上传和下载功能(转)

    原文地址: EBS开发附件上传和下载功能 上传 Oracle ERP二次开发中使用的方式有两种,一是通过标准功能,在系统管理员中定义即可,不用写代码,就可以使几乎任何Form具有附件功能,具体参考系统 ...

随机推荐

  1. 线性时间O(n)内求数组中第k大小的数

    --本文为博主原创,转载请注明出处 因为最近做的WSN(wireless sensor network)实验要求用3个传感器节点接受2000个包的数据并算出一些统计量,其中就有算出中位数这么一个要求, ...

  2. 网络服务器之HTTPS服务

    import ssl, socket, time if __name__ == "__main__": context = ssl.SSLContext(ssl.PROTOCOL_ ...

  3. sql条件为空查询全部,不为空按条件查询以及多条件筛选查询。

    procedure queryLackLonOrLatTdCell(i_region_name varchar2, i_state varchar2) is begin select region_n ...

  4. 基于Redis的爬虫平台的实现

    一.需求: 1.数据抓取:目标数据的下载.解析.入库功能. 2.数据服务:黑名单.灰名单等查询服务. 3.平台监控:平台各个模块的数据实时监控. 二.WEB端效果展示: 三.架构设计 下载器.解析器. ...

  5. Tomcat-问题解决

    1,两种方法解决tomcat的 Failed to initialize end point associated with ProtocolHandler ["http-apr-8080& ...

  6. jQuery 跨域访问的三种方式 No 'Access-Control-Allow-Origin' header is present on the reque

    问题: XMLHttpRequest cannot load http://v.xxx.com. No 'Access-Control-Allow-Origin' header is present ...

  7. 正则表达式/g与/i及/gi的意义

    g: 全局匹配 i: 忽略大小写 gi: 全局匹配 + 忽略大小写

  8. c语言第8次作业

    #include<stdio.h> int main() { ]={}; int m; ; ;m<;m++) { a[m]=m+; !=&&a[m]%!=) n++; ...

  9. XPath、XQuery 以及 XSLT 函数

    存取函数 名称 说明 fn:node-name(node) 返回参数节点的节点名称. fn:nilled(node) 返回是否拒绝参数节点的布尔值. fn:data(item.item,...) 接受 ...

  10. 详解JS跨域问题

    什么是跨域? 概念:只要协议.域名.端口有任何一个不同,都被当作是不同的域.             JavaScript   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...