1
935090232@qq.com
2020-12-01 611146e69aaa62296cf84f2ccb5aca5ebba17677
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*set handlers here*/
var swfuploadhandler={
    init:function(settings,index){
        settings=$.extend(true,{},swfuploadefaults,settings);
        swfuploadhandler["SWFUPLOAD_"+settings.custom_settings.form.attr("id")+"_"+index]=new SWFUpload(settings);
    },
    
    swfUploadLoaded:function(){
            
    },
    
    uploadStart:function(){
        //this.customSettings.form.find(".fsUploadProgress").show();
    },
    
    uploadDone:function(){
        //this.customSettings.form.find(".fsUploadProgress").hide();
        this.customSettings.showmsg("已成功上传文件!",2);
        //this.customSettings.form.submit();
    },
    
    fileDialogStart:function(){
        this.customSettings.form.find("input[plugin='swfupload']").val("");
        this.cancelUpload();
    },
    
    fileQueueError:function(file, errorCode, message){
        try {
            // Handle this error separately because we don't want to create a FileProgress element for it.
            switch (errorCode) {
            case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
                this.customSettings.showmsg("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")),3);
                return;
            case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
                this.customSettings.showmsg("The file you selected is too big.",3);
                this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                return;
            case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
                this.customSettings.showmsg("The file you selected is empty.  Please select another file.",3);
                this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                return;
            case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
                this.customSettings.showmsg("The file you choose is not an allowed file type.",3);
                this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                return;
            default:
                swfu.customSettings.showmsg("An error occurred in the upload. Try again later.",3);
                this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                return;
            }
        } catch (e) {}    
    },
    
    fileQueued:function(file){
        try {
            this.customSettings.form.find("input[plugin='swfupload']").val(file.name);
        } catch (e) {}
    },
    
    fileDialogComplete:function(numFilesSelected, numFilesQueued){
        this.startUpload();
    },
    
    uploadProgress:function(file, bytesLoaded, bytesTotal){
        try {
            var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
            this.customSettings.showmsg("已上传:"+percent+"%",1);
            //this.customSettings.form.find(".fsUploadProgress").text("已上传:"+percent+"%");
        } catch (e) {}
    },
    
    uploadSuccess:function(file, serverData){
        try {
            if (serverData === " ") {
                this.customSettings.upload_successful = false;
            } else {
                this.customSettings.upload_successful = true;
                this.customSettings.form.find("input[pluginhidden='swfupload']").val(serverData);
            }
        } catch (e) {}
    },
    
    uploadComplete:function(file){
        try {
            if (this.customSettings.upload_successful) {
                //this.setButtonDisabled(true);
                swfuploadhandler.uploadDone.call(this);
            } else {
                this.customSettings.form.find("input[plugin='swfupload']").val("");
                this.customSettings.showmsg("There was a problem with the upload.\nThe server did not accept it.",3);
            }
        } catch (e) {}    
    },
    
    uploadError:function(file, errorCode, message){
        try {
            if (errorCode === SWFUpload.UPLOAD_ERROR.FILE_CANCELLED) {
                // Don't show cancelled error boxes
                return;
            }
            this.customSettings.form.find("input[plugin='swfupload']").val("");
    
            // Handle this error separately because we don't want to create a FileProgress element for it.
            switch (errorCode) {
            case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
                this.customSettings.showmsg("There was a configuration error.  You will not be able to upload a resume at this time.",3);
                this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + message);
                return;
            case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
                this.customSettings.showmsg("You may only upload 1 file.",3);
                this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                return;
 
            case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
            case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
                break;
            default:
                this.customSettings.showmsg("An error occurred in the upload. Try again later.",3);
                this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                return;
            }
        } catch (ex) {}
    }
    
}
 
var swfuploadefaults={
    file_size_limit : "10 MB",
    file_types : "*.*",
    file_types_description : "All Files",
    file_upload_limit : "0",
    file_queue_limit : "10",
    button_placeholder_id : "spanButtonPlaceholder",
    
    file_post_name: "resume_file",
    upload_url: "demo/plugin/swfupload/upload.php",
    button_image_url: "demo/plugin/swfupload/XPButtonUploadText_61x22.png",
    button_width: 61,
    button_height: 22,
    flash_url: "demo/plugin/swfupload/swfupload.swf",
    
    swfupload_loaded_handler : swfuploadhandler.swfUploadLoaded,
    file_dialog_start_handler: swfuploadhandler.fileDialogStart,
    file_queued_handler : swfuploadhandler.fileQueued,
    file_queue_error_handler : swfuploadhandler.fileQueueError,
    file_dialog_complete_handler : swfuploadhandler.fileDialogComplete,
    upload_start_handler : swfuploadhandler.uploadStart,
    upload_progress_handler : swfuploadhandler.uploadProgress,
    upload_error_handler : swfuploadhandler.uploadError,
    upload_success_handler : swfuploadhandler.uploadSuccess,
    upload_complete_handler : swfuploadhandler.uploadComplete,
 
    custom_settings:{},
    debug: false
}
 
//$(function(){
    //独立触发事件;
    //var custom={
    //    custom_settings:{
    //        form:$this,
    //        showmsg:function(msg){
    //            alert(msg);    
    //        }    
    //    }    
    //}
    //swfuploadhandler.init(custom);    
//})