Extjs uploadDialog

Extjs里文件上传需要扩展的组件,自己在做extjs例子,没有什么好的方法,网上找的也有很多不同的方法,我用的是Ext.ux.UploadDialog。
在文件里引用

xml 代码
 
  1. <script type="text/javascript" src="lib/extjs.ux/Ext.ux.UploadDialog.js" ></script>  
  2. <script type="text/javascript" src="lib/extjs.ux/Ext.ux.ProgressBar.js" ></script>  
  3. <link rel="stylesheet" type="text/css" href="css/Ext.ux.ProgressBar.css"/>  
  4. <link rel="stylesheet" type="text/css" href="css/Ext.ux.UploadDialog.css"/>  

然后在js的代码里加入:

js 代码
 
  1. var dialog = new Ext.ux.UploadDialog.Dialog(null, {  
  2.           autoCreate: true,  
  3.           closable: true,  
  4.           collapsible: false,  
  5.           draggable: true,  
  6.           minWidth: 400,        
  7.           minHeight: 200,  
  8.           width: 400,  
  9.           height: 350,  
  10.           permitted_extensions:['JPG','jpg','jpeg','JPEG','GIF','gif'],  
  11.           proxyDrag: true,  
  12.           resizable: true,  
  13.           constraintoviewport: true,  
  14.           title: '文件上传',  
  15.           url: 't_file_upload.php',  
  16.           reset_on_hide: false,  
  17.           allow_close_on_upload: true  
  18.         });  

在上传按钮单击时弹出上传对话框:

js 代码
 
  1. btnUpload.on("click",function(){  
  2.                         dialog.show();  
  3.                     });  

下面要做的事情就是在t_file_upload.php这个文件里面来处理上传后的操作了:

java 代码
 
  1. <?php  
  2.     $file = "";  
  3.     $result = array();  
  4.     $ext = strrchr($_FILES["file"]["name"],'.');  
  5.     $file = "". date("YmdHis") . $ext;        
  6.     if(move_uploaded_file($_FILES["file"]["tmp_name"],"images/upload/" . $file)){  
  7.         $result = array('success'=>true,data=>$file);  
  8.     }else{  
  9.         $result = array('success'=> false, 'error'=> '文件上传错误');  
  10.     }                 
  11.     echo json_encode($result);    
  12. ?>  
上传文件的内容就是file,是规定好的:)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值