- 浏览: 518598 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (299)
- Oracle(pl/sql_Erp_Pro*C) (69)
- 设计模式 (4)
- spring (23)
- ext (17)
- apache开源项目应用 (4)
- jquery (16)
- 生活琐事 (8)
- 下载资源 (23)
- mysql (2)
- Eclipse使用积累 (5)
- 报表类(报表/图表) (13)
- php (4)
- Web多彩文本框 (3)
- json (4)
- jqgrid (2)
- ant (2)
- java算法积累 (8)
- EL表达式/JSTL (4)
- poi (3)
- gwt (2)
- 爬网第一步 (2)
- javascript (17)
- Javaweb (8)
- tomcat (1)
- flex (1)
- Java&DB (3)
- J2SE (7)
- linux (3)
- 数据结构 (1)
- dot net (5)
- struts (1)
- ibatis (1)
- log4j (1)
- 项目管理 (1)
- Java native interface(jni,jacob......) (5)
- applet (1)
- VB.net/C#.net/JNI (20)
- css (1)
- Sqlite (1)
- servlet (1)
- REST (1)
最新评论
-
wenhurena:
能不能给一下解压密码roki.work.2017@gmail. ...
Ebs解体新書と学習資料1 -
liutao1600:
楼主写的太好了,每天学习~~
Spring_MVC(6)测试 -
liutao1600:
太好了,每天学习你的文章~~~
Spring_MVC(3)表单页面处理 -
liutao1600:
学习了,太好了
Spring_MVC(2)控制层处理 -
liutao1600:
学习了~~~
Spring_MVC(1)构建简单web应用
http://dev.sencha.com/deploy/dev/examples/form/file-upload.html
file-upload.zip是js代码
fileuploadfield.zip是组建库(EXT官网自带的)
详细代码如下:
html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>File Upload Field Example</title> <!-- ** CSS ** --> <!-- base library --> <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" /> <!-- overrides to base library --> <!-- page specific --> <link rel="stylesheet" type="text/css" href="../shared/examples.css" /> <link rel="stylesheet" type="text/css" href="../ux/fileuploadfield/css/fileuploadfield.css"/> <style type=text/css> .upload-icon { background: url('../shared/icons/fam/image_add.png') no-repeat 0 0 !important; } #fi-button-msg { border: 2px solid #ccc; padding: 5px 10px; background: #eee; margin: 5px; float: left; } </style> <!-- ** Javascript ** --> <!-- ExtJS library: base/adapter --> <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script> <!-- ExtJS library: all widgets --> <script type="text/javascript" src="../../ext-all.js"></script> <!-- overrides to base library --> <script type="text/javascript" src="../ux/fileuploadfield/FileUploadField.js"></script> <!-- page specific --> <script type="text/javascript" src="file-upload.js"></script> </head> <body> <h1>File Upload Field</h1> <p>This example utilizes a custom extension to implement a file upload field. The js is not minified so it is readable. See <a href="file-upload.js">file-input.js</a> and <a href="../ux/fileuploadfield/FileUploadField.js">FileUploadField.js</a>.</p> <p> <b>Basic FileUpload</b><br /> A typical file upload field with Ext style. Direct editing of the text field cannot be done in a consistent, cross-browser way, so it is always read-only in this implementation. <div id="fi-basic"></div> <div id="fi-basic-btn"></div> </p> <p> <b>Basic FileUpload (Button-only)</b><br /> You can also render the file input as a button without the text field, with access to the field's value via the standard <tt>Ext.form.TextField</tt> interface or by handling the <tt>fileselected</tt> event (as in this example). <div id="fi-button"></div> <div id="fi-button-msg" style="display:none;"></div> <div class="x-clear"></div> </p> <p> <b>Form Example</b><br /> The FileUploadField can also be used in standard form layouts, with support for anchoring, validation (the field is required in this example), empty text, etc. This example also demonstrates using the <tt>buttonCfg</tt> option to provide a customized icon upload button. <div id="fi-form"></div> </p> </body> </html>
ext组建库
/*! * Ext JS Library 3.2.1 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ Ext.ns('Ext.ux.form'); /** * @class Ext.ux.form.FileUploadField * @extends Ext.form.TextField * Creates a file upload field. * @xtype fileuploadfield */ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, { /** * @cfg {String} buttonText The button text to display on the upload button (defaults to * 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text * value will be used instead if available. */ buttonText: 'Browse...', /** * @cfg {Boolean} buttonOnly True to display the file upload field as a button with no visible * text field (defaults to false). If true, all inherited TextField members will still be available. */ buttonOnly: false, /** * @cfg {Number} buttonOffset The number of pixels of space reserved between the button and the text field * (defaults to 3). Note that this only applies if {@link #buttonOnly} = false. */ buttonOffset: 3, /** * @cfg {Object} buttonCfg A standard {@link Ext.Button} config object. */ // private readOnly: true, /** * @hide * @method autoSize */ autoSize: Ext.emptyFn, // private initComponent: function(){ Ext.ux.form.FileUploadField.superclass.initComponent.call(this); this.addEvents( /** * @event fileselected * Fires when the underlying file input field's value has changed from the user * selecting a new file from the system file selection dialog. * @param {Ext.ux.form.FileUploadField} this * @param {String} value The file value returned by the underlying file input field */ 'fileselected' ); }, // private onRender : function(ct, position){ Ext.ux.form.FileUploadField.superclass.onRender.call(this, ct, position); this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'}); this.el.addClass('x-form-file-text'); this.el.dom.removeAttribute('name'); this.createFileInput(); var btnCfg = Ext.applyIf(this.buttonCfg || {}, { text: this.buttonText }); this.button = new Ext.Button(Ext.apply(btnCfg, { renderTo: this.wrap, cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '') })); if(this.buttonOnly){ this.el.hide(); this.wrap.setWidth(this.button.getEl().getWidth()); } this.bindListeners(); this.resizeEl = this.positionEl = this.wrap; }, bindListeners: function(){ this.fileInput.on({ scope: this, mouseenter: function() { this.button.addClass(['x-btn-over','x-btn-focus']) }, mouseleave: function(){ this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']) }, mousedown: function(){ this.button.addClass('x-btn-click') }, mouseup: function(){ this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']) }, change: function(){ var v = this.fileInput.dom.value; this.setValue(v); this.fireEvent('fileselected', this, v); } }); }, createFileInput : function() { this.fileInput = this.wrap.createChild({ id: this.getFileInputId(), name: this.name||this.getId(), cls: 'x-form-file', tag: 'input', type: 'file', size: 1 }); }, reset : function(){ this.fileInput.remove(); this.createFileInput(); this.bindListeners(); Ext.ux.form.FileUploadField.superclass.reset.call(this); }, // private getFileInputId: function(){ return this.id + '-file'; }, // private onResize : function(w, h){ Ext.ux.form.FileUploadField.superclass.onResize.call(this, w, h); this.wrap.setWidth(w); if(!this.buttonOnly){ var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset; this.el.setWidth(w); } }, // private onDestroy: function(){ Ext.ux.form.FileUploadField.superclass.onDestroy.call(this); Ext.destroy(this.fileInput, this.button, this.wrap); }, onDisable: function(){ Ext.ux.form.FileUploadField.superclass.onDisable.call(this); this.doDisable(true); }, onEnable: function(){ Ext.ux.form.FileUploadField.superclass.onEnable.call(this); this.doDisable(false); }, // private doDisable: function(disabled){ this.fileInput.dom.disabled = disabled; this.button.setDisabled(disabled); }, // private preFocus : Ext.emptyFn, // private alignErrorIcon : function(){ this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]); } }); Ext.reg('fileuploadfield', Ext.ux.form.FileUploadField); // backwards compat Ext.form.FileUploadField = Ext.ux.form.FileUploadField;
js
/*! * Ext JS Library 3.2.1 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ Ext.onReady(function(){ Ext.QuickTips.init(); var msg = function(title, msg){ Ext.Msg.show({ title: title, msg: msg, minWidth: 200, modal: true, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }; var fibasic = new Ext.ux.form.FileUploadField({ renderTo: 'fi-basic', width: 400 }); new Ext.Button({ text: 'Get File Path', renderTo: 'fi-basic-btn', handler: function(){ var v = fibasic.getValue(); msg('Selected File', v && v != '' ? v : 'None'); } }); var fbutton = new Ext.ux.form.FileUploadField({ renderTo: 'fi-button', buttonOnly: true, listeners: { 'fileselected': function(fb, v){ var el = Ext.fly('fi-button-msg'); el.update('<b>Selected:</b> '+v); if(!el.isVisible()){ el.slideIn('t', { duration: .2, easing: 'easeIn', callback: function(){ el.highlight(); } }); }else{ el.highlight(); } } } }); var fp = new Ext.FormPanel({ renderTo: 'fi-form', fileUpload: true, width: 500, frame: true, title: 'File Upload Form', autoHeight: true, bodyStyle: 'padding: 10px 10px 0 10px;', labelWidth: 50, defaults: { anchor: '95%', allowBlank: false, msgTarget: 'side' }, items: [{ xtype: 'textfield', fieldLabel: 'Name' },{ xtype: 'fileuploadfield', id: 'form-file', emptyText: 'Select an image', fieldLabel: 'Photo', name: 'photo-path', buttonText: '', buttonCfg: { iconCls: 'upload-icon' } }], buttons: [{ text: 'Save', handler: function(){ if(fp.getForm().isValid()){ fp.getForm().submit({ url: 'file-upload.php', waitMsg: 'Uploading your photo...', success: function(fp, o){ msg('Success', 'Processed file "'+o.result.file+'" on the server'); } }); } } },{ text: 'Reset', handler: function(){ fp.getForm().reset(); } }] }); });
- file-upload.zip (1.1 KB)
- 下载次数: 311
- FileUploadField.zip (1.7 KB)
- 下载次数: 279
发表评论
-
Ext tree add update delete
2010-09-26 16:33 1484Ext.onReady(function() { // 树 ... -
Ext树操作
2010-09-26 13:04 1123后台树节点定义 menu_info { menu_ ... -
Ext动态grid
2010-08-24 23:54 1601在做报表的时候,需要 ... -
Extjs 工具
2010-08-19 12:24 831调试工具:调试ExtJs利器 - Firebug( ... -
Extjs uploadDialog
2010-08-16 13:08 1773Extjs里文件上传需要扩展的组件,自己在做extjs例子,没 ... -
Extjs php fileupload
2010-08-16 13:00 1609upload.html <html> < ... -
ext renderer
2010-08-10 22:04 2322renderer:function(value, cellm ... -
timefield demo
2010-08-09 15:10 1184<mce:script type="text/ ... -
ext datefield timefield and format
2010-08-09 15:06 2159DateField TimeField 日期控件 时间控件 日 ... -
Extjs form
2010-08-07 19:30 3195OK,前面我们已经学过了GridPanel,TabPanel ... -
Extjs 学习
2010-08-07 11:45 714http://blog.csdn.net/lenotang/a ... -
深入浅出Ext_JS:数据存储与传输
2010-07-09 15:44 775附件 -
ext radiogroup
2010-07-06 21:10 2510Ext.onReady(function () { ... -
Ext builder 和ext网站
2010-06-28 09:05 947http://tof2k.com/ext/formbuilde ... -
extjs 打印
2010-06-22 20:56 2543function () { /** * Pr ... -
Extjs提交数据
2010-06-17 17:43 1362Ext JS FormPanel 提交数据 ...
相关推荐
本篇文章将聚焦于"Ext上传文件例子(入门)",通过一个简单的实例来讲解如何在ExtJS框架下实现文件上传功能。 首先,我们要理解文件上传的基本原理。在Web应用中,文件上传通常依赖于HTML的`<input type="file">`元素...
### Struts2与ExtJS集成实现文件的上传、下载与删除功能详解 #### 一、项目背景与技术栈概述 本案例旨在通过Struts2框架与ExtJS前端库的结合来实现文件的批量上传、下载以及删除功能。适用于对Struts2与ExtJS有...
首先,EXTJS 提供了`Ext.form.Basic`和`Ext.form.FieldSet`等组件,它们可以用来创建表单,包括文件上传字段。文件上传通常涉及到HTML的`<input type="file">`元素。在EXTJS中,我们可以使用`Ext.form.field.File`...
这个"EXT上传例子"可能包含了一个完整的示例项目,用于演示EXTJS如何实现文件上传功能。下面我们将详细探讨EXTJS中的文件上传以及相关的JavaScript技术。 1. **EXTJS组件:FileField** EXTJS 提供了`Ext.form....
体验例子见:http://extjs.com/deploy/dev/examples/form/file-upload.html 2、GMapPanel GMap扩展 体验例子见:http://extjs.com/deploy/dev/examples/window/gmap.html 3、XmlTreeLoader XML转换成Tree ...
Struts2和ExtJS3是两个非常流行的开源框架,它们在Web开发中有着广泛的应用。Struts2是一个基于MVC(Model-View-Controller)设计模式的Java Web框架,而ExtJS3则是一个用于构建富客户端JavaScript应用的库。本文将...
<%@ taglib prefix="ext" uri="http://extjs.com/tags" %> ... <ext:FormPanel id="uploadForm" width="400" layout="form"> <ext:TextField fieldLabel="文件名" name="filename"></ext:TextField> <ext:...
Ext.ux.UploadDialog 是一个 ExtJS 框架的扩展组件,它提供了一个友好的用户界面来处理文件上传。在服务器端,我们需要正确解析接收到的请求,以便能够读取并处理上传的文件。在 Java 环境下,Apache Commons ...
以下是一个使用`float`属性实现并排布局的例子: ```java public class FloatLayoutExample extends Composite { public FloatLayoutExample() { VerticalPanel root = new VerticalPanel(); initWidget(root); ...