zoukankan      html  css  js  c++  java
  • Jquery学习---一键上传

    一键上传

    jar包下载

    jquery代码

        $(function () {  
                    $(".uploadfile").upload({  
                        action: 'CourseXMLFileUploadHander.ashx',  
                        name: 'xml',  
                        params: {  
                            'type': 'uploadCourseXMLFile',  
                            'rand': Math.random()  
                        },  
                        onSelect: function (self, element) {  
                            this.autoSubmit = false;  
                            var re = new RegExp("(xml){1}quot;, "i");  
          
                            if (!re.test(this.filename())) {  
                                alert("Only xml file can be uploaded");  
                            }  
                            else {  
                                this.submit();  
                            }  
                        },  
                        onSubmit: function (self, element) {  
                            $('.uploadfile').hide();  
                            $('#ajax_update').parent().show();  
                            //alert('Uploading file...');  
                        },  
                        onComplete: function (data, self, element) {  
                            $('#ajax_update').parent().hide();  
                            $('.uploadfile').show();  
                            self.resetInput();  
                            try {  
                                var ret = data;  
                                if (ret.indexOf("exception") >= 0) {  
                                    alert('Upload file exception: ' + eval(data)[0].exception);  
                                }  
                                else {  
                                    showSuccess('File is successfully Load.');  
          
                                    uploadSuccess(ret);  
          
                                }  
                            } catch (err) {  
                                alert(data);  
                            }  
                        }  
                    });  
                });  
    

      

  • 相关阅读:
    Tomcat部署项目
    正则表达式
    文件的上传和下载
    实现扫码登陆
    onepill Android端
    部署SpringBoot到阿里云
    Gson
    HTML自动刷新页面
    Spring Data JPA根据属性名查询
    Spring Date JPA实现增删改查
  • 原文地址:https://www.cnblogs.com/ftl1012/p/9357405.html
Copyright © 2011-2022 走看看