Ext.onReady(function() {
var dialog = new Ext.ux.UploadDialog.Dialog(null,
{
autoCreate : true,
closable : true,
collapsible : false,
draggable : true,
minWidth : 500,
minHeight : 200,
width : 400,
height : 350,
proxyDrag : true,
resizable : true,
//permitted_extensions : ['JPG', 'jpg', 'jpeg', 'JPEG', 'GIF', 'gif','doc','xls'],
constraintoviewport : true,
title : '文件上传的例子',
url : '/NewSMS/fileupload',
reset_on_hide : false,
allow_close_on_upload : true
});
dialog.show('my-dlg');
});
package com.hiber;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.commons.fileupload.*;
public class Upload extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 7440302204266787092L;
String uploadPath = "d:\\"; // 用于存放上传文件的目录
String tempPath = "d:\\tmp\\"; // 用于存放临时文件的目录
public Upload(){
super();
System.out.println("文件上传启动");
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void init() throws ServletException {
System.out.println("文件上传初始化");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
try {
System.out.println("开始进行文件上传");
DiskFileUpload fu = new DiskFileUpload();
fu.setSizeMax(4194304); // 设置最大文件尺寸,这里是4MB
fu.setSizeThreshold(4096); // 设置缓冲区大小,这里是4kb
fu.setRepositoryPath(tempPath); // 设置临时目录
List fileItems = fu.parseRequest(request); // 得到所有的文件:
Iterator i = fileItems.iterator();
// 依次处理每一个文件:
while (i.hasNext()) {
FileItem fi = (FileItem) i.next();
String fileName = fi.getName();// 获得文件名,这个文件名包括路径:
if (fileName != null) {
// 在这里可以记录用户和文件信息
// 此处应该定义一个接口(CallBack),用于处理后事。
// 写入文件a.txt,你也可以从fileName中提取文件名:
fi.write(new File(uploadPath + "a.txt"));
}
}
response.setContentType("text/html;charset=utf-8");
response.getWriter().print("{success:true,msg:'成功'}");
// 跳转到上传成功提示页面
} catch (Exception e) {
response.getWriter().print("{success:flase,msg:'失败'}");
// 可以跳转出错页面
}
}
}
分享到:
相关推荐
The class is ready for i18n, override the Ext.ux.UploadDialog.Dialog.prototype.i18n object with your language strings, or just pass i18n object in config. Server side handler. The files in the queue...
ext.ux.uploadDialog实例
工程文件 博文链接:https://mutongwu.iteye.com/blog/693692
在做文件上传的时候,发现了Ext.ux.UploadDialog这个强大的东西,实现了一下
Ext.ux.dialog Common-fileupload 整合版! <br>Ext文件上传完整包
//implementation 'moe.shizuku.preference:preference-dialog-appcompat:' // if you want to use appcompat version dialog //implementation 'moe.shizuku.preference:preference-switchcompat:' // appcompat v
JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display...A warning dialog windows appear because "org.jd.ide.eclipse.plugin_x.y.z.jar" is not signed. Click on "Install anyway" button.
版本错误的处理Install Repository and sync project show in file Show in Project Structure dialog
Show in Project Structure dialog 或者 ERROR: Failed to resolve: com.serenegiant:common:1.5.20 Show in Project Structure dialog ``` 报这个错误是因为无法下载com.serenegiant:common 原因,我使用...
the DragImage doesn't overlap dialog windows anymore. Bugfix - TJamShellList: If file extensions are hidden in Windows, they are no longer shown if a file is renamed in the TJamShellList. Bugfix - ...
8)....Added: Exception line highlighting in disassember view in EurekaLog exception dialog and Viewer 9)....Added: Detection/logging Delphi objects in disassembly view 10)..Added: Support for multi-...
学习YUI.Ext 第四天--对话框Dialog的使用
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:dialogflow-1.1.2-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
jQuery对话框Dialog弹出层插件演示与使用说明
近几天大家反映的问题,都会得到改善,请及时使用最新版本。模块导航:SmartToastSmartSnackbarSmartTopBarSmartDialog关于实现关于作者及微信交流群引入该库功能总览:优雅封装,简化调用处理系统bug等,如Android ...
Open the Diver Manager dialog ("Tools" > "Driver Manager...") and hit the "Create a new driver" icon. Fill in the information as seen below. For the "Driver File Paths" you are pointing to hive-jdbc-...
看到这个sweet-alert-dialog很亲切,因为前端开发本人用的提示就是这个js插件,java牛人很厉害,直接弄成一个java包插件,Good!...我下载的是:sweet-alert-dialog-1.1版本zip包 将下载sweet-alert-di
Sencha Ext JS的文件上传小部件 特征 灵活且易于集成 ... 允许一次选择和上传多个文件 支持原始 PUT/POST 上传和分段上传 您可以轻松编写和集成自己的上传机制,同时保留所有(或大... var dialog = Ext.create('Ext.ux.up