EXTJS使用H5 formdata实现多文件上传

 var formWin=Ext.create('Ext.window.Window', {
	    layout: 'fit',
	    width: 350,
	    closable: true,
	    modal: true,
	    scrollable:true,
	    id:'backupsFormWin',
	    items: [
	        {
	            id:'backupsForm',
	            scrollable:true,
	            xtype: 'form',
	            padding: '5 5 0 5',
	            border: false,
	            style: 'background-color: #fff',
	            
	
	            fieldDefaults: {
	                anchor: '100%',
	                labelAlign: 'left',
	                combineErrors: true,
	                msgOnlineResource: 'side',
	                fieldCls: 'fixed' //fix for textfield text in Chrome
	            },
	
	            items: [
	                {
	                    xtype:'panel',                     
	                    border: false,
	                    id:'panel',
	                    items:[{closable:false,html:'<div class="file"><form name="backupsFiles" enctype="multipart/form-data" method="post">' +
	                            '<input  onchange="changeSelectFileNames(this.value)" style="font-size:15px;padding-bottom:3px;" type="file"  ' +
	                            'name="uploadFile" id="uploadFileBtn" multiple=true/></form><label id="selectFileNamesLabel">未选择文件</label><button onclick="selectFile()" class="btn">选择文件</button></div>'}]
	                }          
	            ]
	        }
	    ],
有些css样式如下
<pre name="code" class="css">.file input {
    font-size: 13px;
    right: 0;
    top: 0;
    opacity: 0;
    visibility:hidden;
}

.file label{
    position: relative;
    display: inline-block;
    width:180px;
    border: 1px solid #99D3F5;
    overflow: hidden;
    color: #1E88C7;
    text-decoration: none;
    text-indent: 0;
    height: 40px;
    bottom:33px;
    left:10px;
    padding-top:12px;
}

.file .btn{
	position: relative;
	display: inline-block;
	border:none;
	height:40px;
	background-color:#5FA2DD;
	color:white;
	width:80px;
    bottom:49px;
    margin-left: 30px;
}

 

 

 

 

 

sendform方法如下<pre name="code" class="javascript">	var myMask=null;
	this.sendForm=function(){
	  var oData = new FormData(document.forms.namedItem("backupsFiles"));
	  oData.append("path", path);
	  var oReq = new XMLHttpRequest();
	  oReq.open("POST", "url", true);
	  oReq.onload = function(oEvent) {
	    if (oReq.status == 200) {
	       Ext.Msg.alert("提示","保存成功");
	       Ext.getBody().unmask();
	       checkFile(path);
	    } else {
	       Ext.Msg.alert("提示信息","错误码:"+oReq.status);
	    }
	  };
	   Ext.getCmp('backupsFormWin').hide();
	   myMask = Ext.getBody().mask("正在上传...","x-mask-loading");
	   oReq.send(oData);
	
	}

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值