zoukankan      html  css  js  c++  java
  • extjs 文件上传例子

    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.            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,是规定好的:)
    附件中上传的是组件库
  • 相关阅读:
    解释一下,@SpringBootApplication
    mybatis的一堆多映射使用配置
    SSM基础pom和xml的整合配置
    获取form表单所有数据最快方式
    两个大神的配置
    springmvc 注解详解
    自适应组件导航栏
    文本相似度的衡量之余弦相似度
    Pandas系列(十四)- 实战案例
    selenium常用操作
  • 原文地址:https://www.cnblogs.com/hannover/p/1890828.html
Copyright © 2011-2022 走看看