github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/tinymce/plugins/jbimages/dialog-v4.htm (about) 1 <!DOCTYPE html> 2 <html lang="zh_CN"> 3 <head> 4 <meta charset="utf-8"> 5 <meta content="xxxx" name="_xsrf" /> 6 <title>上传图片</title> 7 <script type="text/javascript" src="js/dialog-v4.js"></script> 8 <link href="css/dialog-v4.css" rel="stylesheet" type="text/css"> 9 <style> 10 *{margin:0;padding:0;} 11 a{text-decoration:none;} 12 .btn_addPic{ 13 display: block; 14 position: relative; 15 width: 100%; 16 height: 128px; 17 overflow: hidden; 18 border: 1px solid #EBEBEB; 19 background: none repeat scroll 0 0 #F3F3F3; 20 color: #999999; 21 cursor: pointer; 22 text-align: center; 23 } 24 .btn_addPic span{display: block;line-height: 128px;font-size: 12px;} 25 .btn_addPic em { 26 background:url("img/ico.png") 0 0; 27 display: inline-block; 28 width: 18px; 29 height: 18px; 30 line-height: 128px; 31 overflow: hidden; 32 margin: 10px 5px 10px 0; 33 vertical-align: middle; 34 text-align: center; 35 } 36 .btn_addPic:hover em{background-position:-19px 0;} 37 .filePrew { 38 display: block; 39 position: absolute; 40 text-align: center; 41 top: 0; 42 left: 0; 43 width: 100%; 44 height: 128px; 45 font-size: 100px; /* 增大不同浏览器的可点击区域 */ 46 opacity: 0; /* 实现的关键点 */ 47 filter:alpha(opacity=0);/* 兼容IE */ 48 } 49 </style> 50 </head> 51 <body> 52 <form class="form-inline" id="upl" name="upl" action="/api/upload/" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="jbImagesDialog.inProgress();"> 53 <div id="upload_in_progress" class="upload_infobar"> 54 <img src="img/spinner.gif" width="16" height="16" class="spinner" style="text-align: center;line-height: 128px;"> 55 正在上传… 56 <div id="upload_additional_info"></div> 57 </div> 58 <div id="upload_infobar" class="upload_infobar"></div> 59 <p id="upload_form_container"> 60 <a class="btn_addPic" href="javascript:void(0);"> 61 <span> <em></em> 62 请点击此区域,选取图片后自动上传(~.~) 63 </span> 64 <input id="uploader" class="filePrew" name="uploadfile" type="file" class="jbFileBox" onChange="document.upl.submit(); jbImagesDialog.inProgress();"></a> 65 </p> 66 </form> 67 68 <script> 69 var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 70 var base64DecodeChars = new Array( 71 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 72 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 73 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 74 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, 75 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 76 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, 77 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 78 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); 79 80 function base64encode(str) { 81 var out, i, len; 82 var c1, c2, c3; 83 len = str.length; 84 i = 0; 85 out = ""; 86 while(i < len) { 87 c1 = str.charCodeAt(i++) & 0xff; 88 if(i == len) 89 { 90 out += base64EncodeChars.charAt(c1 >> 2); 91 out += base64EncodeChars.charAt((c1 & 0x3) << 4); 92 out += "=="; 93 break; 94 } 95 c2 = str.charCodeAt(i++); 96 if(i == len) 97 { 98 out += base64EncodeChars.charAt(c1 >> 2); 99 out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); 100 out += base64EncodeChars.charAt((c2 & 0xF) << 2); 101 out += "="; 102 break; 103 } 104 c3 = str.charCodeAt(i++); 105 out += base64EncodeChars.charAt(c1 >> 2); 106 out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); 107 out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)); 108 out += base64EncodeChars.charAt(c3 & 0x3F); 109 } 110 return out; 111 } 112 113 function base64decode(str) { 114 var c1, c2, c3, c4; 115 var i, len, out; 116 len = str.length; 117 i = 0; 118 out = ""; 119 while(i < len) { 120 /* c1 */ 121 do { 122 c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; 123 } while(i < len && c1 == -1); 124 if(c1 == -1) 125 break; 126 /* c2 */ 127 do { 128 c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; 129 } while(i < len && c2 == -1); 130 if(c2 == -1) 131 break; 132 out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4)); 133 /* c3 */ 134 do { 135 c3 = str.charCodeAt(i++) & 0xff; 136 if(c3 == 61) 137 return out; 138 c3 = base64DecodeChars[c3]; 139 } while(i < len && c3 == -1); 140 if(c3 == -1) 141 break; 142 out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2)); 143 /* c4 */ 144 do { 145 c4 = str.charCodeAt(i++) & 0xff; 146 if(c4 == 61) 147 return out; 148 c4 = base64DecodeChars[c4]; 149 } while(i < len && c4 == -1); 150 if(c4 == -1) 151 break; 152 out += String.fromCharCode(((c3 & 0x03) << 6) | c4); 153 } 154 return out; 155 } 156 157 function utf16to8(str) { 158 var out, i, len, c; 159 out = ""; 160 len = str.length; 161 for(i = 0; i < len; i++) { 162 c = str.charCodeAt(i); 163 if ((c >= 0x0001) && (c <= 0x007F)) { 164 out += str.charAt(i); 165 } else if (c > 0x07FF) { 166 out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); 167 out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); 168 out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 169 } else { 170 out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); 171 out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 172 } 173 } 174 return out; 175 } 176 177 function utf8to16(str) { 178 var out, i, len, c; 179 var char2, char3; 180 out = ""; 181 len = str.length; 182 i = 0; 183 while(i < len) { 184 c = str.charCodeAt(i++); 185 switch(c >> 4) 186 { 187 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: 188 // 0xxxxxxx 189 out += str.charAt(i-1); 190 break; 191 case 12: case 13: 192 // 110x xxxx 10xx xxxx 193 char2 = str.charCodeAt(i++); 194 out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); 195 break; 196 case 14: 197 // 1110 xxxx 10xx xxxx 10xx xxxx 198 char2 = str.charCodeAt(i++); 199 char3 = str.charCodeAt(i++); 200 out += String.fromCharCode(((c & 0x0F) << 12) | 201 ((char2 & 0x3F) << 6) | 202 ((char3 & 0x3F) << 0)); 203 break; 204 } 205 } 206 return out; 207 } 208 209 function getCookie(name) { 210 var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); 211 return r ? r[1] : undefined; 212 } 213 214 function AddElement(mtype){ 215 var mtype,tem=document.getElementById("upl"); 216 var newinput = document.createElement("input"); 217 if (getCookie("_xsrf")) { 218 var parts = getCookie("_xsrf").split("|"); 219 var token = base64decode(parts[0]); 220 newinput.name="_xsrf"; 221 newinput.value= token; 222 //alert( token ); 223 }; 224 newinput.type=mtype; 225 tem.appendChild(newinput); 226 } 227 AddElement("hidden"); 228 </script> 229 <iframe id="upload_target" name="upload_target"></iframe> 230 </body> 231 </html>