cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
[#macro ajaxuploadnew  id="" name=id   allowTypes="*" fileSizeLimit="5000KB" style="" width="240" height="30"]
<script src="${base}/static/plugins/uploadify/jquery.uploadify.min.js" type="text/javascript" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" href="${base}/static/plugins/uploadify/uploadify.css">
 
<style>
.hid {display:none;}
 
.uploadify{
    position:absolute;bottom:0;left:0;font-size:1px;
}
 
.uploadify-queue{
   position:absolute;bottom:10px;left:0;font-size:1px;
}
</style>
 
<script type="text/javascript">
$(function() {
        $("#${id}").uploadify({
            height        : ${height},
            swf           : '${base}/static/plugins/uploadify/uploadify.swf',
            uploader      : '${base}/interface/fileupload/picpressupload.html',
            buttonClass   : 'hid',
            multi           : false,    
            width         : ${width},
            fileTypeExts  : '${allowTypes}',
            fileSizeLimit : '${fileSizeLimit}',
            queueID          : 'abc',
            onError:function(event,queueId,fileObj,errorObj){
                if (errorObj.type === "File Size"){
                    alert('³¬¹ýÎļþÉÏ´«´óСÏÞÖÆ£¨2M£©£¡');
                    return;
                   }
            },
            onUploadSuccess : function(file, data, response){
                    var data =  JSON.parse(data);
                    $("#${id}_TEXT").val(data.FILE_PATH);
                    $("#${id}_IMG").attr("src",'${base}'+data.FILE_PATH);
                    
                    var img = new Image();
                    img.src = '${base}'+data.FILE_PATH;
                    img.onload=function(){
                        if(img.width > img.height){
                            $("#${id}_IMG").css("width","100%");
                            $("#${id}_IMG").css("height","");
                        }else{
                            $("#${id}_IMG").css("height","100%");
                            $("#${id}_IMG").css("width","");
                        }
                    
                    }
                        
                }
        });
})
</script>
 
<input type="file" name="${id}"  id="${id}" style="${style}"/>
[/#macro]