-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.html
336 lines (302 loc) · 12.8 KB
/
upload.html
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Login</title>
<!-- 版本号,每次升级需要修改为对应的版本号,避免缓存造成样式问题 -->
<link rel="stylesheet" href="http://lg-center-static.jm.com/static/css/bootstrap.min.css">
<link rel="stylesheet" href="http://lg-center-static.jm.com/static/css/common.css?v=1.8.2">
<link rel="stylesheet" href="http://lg-center-static.jm.com/static/css/layer.css">
<script src="http://lg-center-static.jm.com/static/js/jquery/jquery-1.11.3.min.js"></script>
<script src="http://lg-center-static.jm.com/static/js/ValidForm/validate2.js"></script>
<script src="http://lg-center-static.jm.com/static/js/layer/layer.js"></script>
<!-- uploadify start -->
<script type="text/javascript">
var fileViewAddress = 'http://image.jm.com';
var fileUploadAddress = 'http://image5.jm.com';
var staticUrl = 'http://lg-center-static.jm.com';
var WEB_FILE_PATH = fileUploadAddress;
var WEB_VIEW_PATH = fileViewAddress;
</script>
<link rel="stylesheet" href="http://lg-center-static.jm.com/static/js/upload/upload.css"/>
<script src="./dep/fine-uploader/fine-uploader.core.js"></script>
<script src="./upload.js"></script>
<script src="./showImage.js"></script>
<!-- uploadify end -->
<!-- 富文本 start -->
<link href="http://center.jzx.com/static/dep/kindeditor/themes/default/default.css" rel="stylesheet" type="text/css">
<link href="http://center.jzx.com/static/css/kindeditor.css" type="text/css" rel="stylesheet"/>
<!-- 方案一 -->
<!--<script src="./dep/kindeditor/kindeditor-all-new.js"></script>-->
<!--<script src="http://center.jzx.com/static/dep/kindeditor/editor_upload.js"></script>-->
<!-- 方案二 -->
<!--<style>
.ke-icon-upload {
background-image: url(http://center.jzx.com/static/dep/kindeditor/themes/default/default.png);
background-position: 0px -496px;
width: 16px;
height: 16px;
}
</style>-->
<!--<script src="./dep/kindeditor/kindeditor-all-o.js"></script>-->
<!--<script src="./dep/kindeditor/kindeditor.upload.js"></script>-->
<!--<script src="./dep/kindeditor/editor_upload-planB.js"></script>-->
<!-- 方案三 -->
<!--<script src="./dep/kindeditor/kindeditor-all-new.js"></script>-->
<!--<script src="./dep/kindeditor/kindeditor.upload.js"></script>-->
<!--<script src="./dep/kindeditor/editor_upload-planC.js"></script>-->
<!-- 方案一 方案二 方案三 demo -->
<style>
.ke-icon-upload {
background-image: url(http://center.jzx.com/static/dep/kindeditor/themes/default/default.png);
background-position: 0px -496px;
width: 16px;
height: 16px;
}
</style>
<script src="./dep/kindeditor/kindeditor-all-new.js"></script>
<script src="./dep/kindeditor/kindeditor.upload.js"></script>
<script src="http://center.jzx.com/static/dep/kindeditor/editor_upload.js"></script>
<script src="./dep/kindeditor/editor_upload-planB.js"></script>
<script src="./dep/kindeditor/editor_upload-planC.js"></script>
<!-- 富文本 end -->
<script type="text/javascript">
//单张图片显示
function showImageMain(imgSrc) {
// 显示完整大图
imgSrc = getFileViewUrl(imgSrc, false);
if (imgSrc) {
var img = new Image();
var layero = parent.layer ? parent.layer : layer;
img.onload = function() {
var wWidth = window.innerWidth * 0.9, wHeight = window.innerHeight * 0.9, width = img.width,
height = img.height;
var scaleMaxWidth = 1;
var scaleMaxHeight = 1;
if (img.width > wWidth) {
scaleMaxWidth = wWidth / img.width;
}
if (img.height > wHeight) {
scaleMaxHeight = wHeight / img.height;
}
var maxScale = Math.min(scaleMaxWidth, scaleMaxHeight);
var area = [maxScale * width + 'px', maxScale * height + 'px'];
layero.open({
type: 1,
title: false,
closeBtn: 1,
area: area,
skin: 'popimg-box', //没有背景色
shadeClose: true,
content: '<img style="" src=' + imgSrc + ' />'
});
};
img.onerror = function(e) {
layero.msg('图片不存在', { time: 1000 });
};
img.src = imgSrc;
}
}
$(function() {
//图片查看
$('body').on('click', '.show-pic', function(e) {
var srcStr = $(this).parent('.change-pic').siblings('img').attr('src');
showImageMain(srcStr);
});
});
</script>
<!-- jyt ui-fix -->
<style>
.file-upload input[type='file']{
left: auto;
width: auto;
}
input.file-btn, #uploadifyText {
display: none;
}
input[name=qqfile] {
display: block !important;
background: #11b95c;
cursor: pointer;
}
</style>
</head>
<body>
<div class="editor-box" style="width:40%">
<div class="form-module">
<!-- 上传图片 -->
<div class="box-header clearfix">
<h3 class="title">上传指定数量图片</h3>
</div>
<div class="form-main">
<form id="uploadForm1" class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2">上传图片</label>
<div class="col-sm-10 p-t-sm">
<!-- 注意 ,很重要,a标签id名称与type=file的id与name=uploadFile有严格要求 -->
<span class="image-upload-wrap">
<a class="image-upload" id="uploadFile_head" validate="required">
<input type="file" class="file-btn" id="uploadFile"/>
<input type="hidden" name="uploadFile"/>
</a>
营业执照
</span>
<span class="image-upload-wrap">
<a class="image-upload" id="uploadFile1_head">
<input type="file" class="file-btn" id="uploadFile1"/>
<input type="hidden" name="uploadFile1"/>
</a>
营业执照编辑
</span>
</div>
</div>
</form>
</div>
<!-- 上传文件 -->
<div class="box-header clearfix">
<h3 class="title">上传文件</h3>
</div>
<div class="form-main">
<form id="uploadForm2" class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2">上传文件</label>
<div class="col-sm-10 p-t-sm">
<div class="input-group file-upload-wrap">
<input type="text" class="form-control" readonly placeholder="请上传doc docx pdf格式的文件"/>
<a class="btn btn-primary btn-block file-upload input-group-addon">
<input type="file" id="uploadifyText"/> 选择文件
</a>
</div>
</div>
<label class="control-label col-sm-2">$(selector) button</label>
<div class="col-sm-10 p-t-sm">
<div class="input-group file-upload-wrap">
<input type="text" class="form-control" readonly placeholder="请上传doc docx pdf格式的文件"/>
<a class="btn btn-primary btn-block file-upload input-group-addon">
<button type="button" id="uploadButton">选择文件</button>
</a>
</div>
</div>
</div>
</form>
</div>
<!-- 上传多张图片 -->
<div class="box-header clearfix">
<h3 class="title">上传多张图片</h3>
</div>
<div class="form-main">
<form id="uploadForm3" class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2">上传图片</label>
<div class="col-sm-10 p-t-sm image-upload-group" data-max="5">
<!-- 注意 ,很重要,a标签id名称与type=file的id与name=uploadFile有严格要求 -->
<span class="image-upload-wrap">
<a class="image-upload" id="uploadFile2_head">
<input type="file" class="file-btn" id="uploadFile2"/>
<input type="hidden" name="uploadFile2"/>
</a>
</span>
</div>
</div>
</form>
</div>
<!-- 富文本 start -->
<div class="box-header clearfix">
<h3 class="title">富文本 方案一</h3>
</div>
<div class="form-main">
<textarea id="descripe" name="descripe" style="width:910px; height:300px"></textarea>
</div>
<div class="box-header clearfix">
<h3 class="title">富文本 方案二</h3>
</div>
<div class="form-main">
<textarea id="descripe2" name="descripe2" style="width:910px; height:300px"></textarea>
</div>
<div class="box-header clearfix">
<h3 class="title">富文本 方案三</h3>
</div>
<div class="form-main">
<textarea id="descripe3" name="descripe3" style="width:910px; height:300px"></textarea>
</div>
<input type="hidden" name="h_webFilePath" value="http://image.jm.com">
<input type="hidden" name="h_webFileUploadPath" value="http://image5.jm.com">
<script>
// 方案一
initEditor({el: "#descripe"});
// 方案二
initEditor2({el: "#descripe2"});
// 方案三
initEditor3({el: "#descripe3"});
</script>
<!-- 富文本 end -->
</div>
</div>
</body>
<script type="text/javascript">
$(function() {
checksub();
//上传图片控件
showImage('uploadFile', null, {
showClear: true, // 显示编辑按钮
callback: function(data, id, name, uploader) {
$('#uploadFile').parent().
removeClass('red-border').
siblings('.poptip').
remove();
layer.alert('编辑成功回调');
}
});
//编辑图片控件 ,3个参数
//param2:string 上传组件id
//param1:对象,filePaths图片路径(数组),originalFileNames文件名称(数组)
//param3:其它配置,参考upload.js
var data = {
filePaths: ['/newupload/www.jmdev.com/PC/2016/12/16/15/57/01/d625bdc87ba6ddf0-jm.jpg'],
originalFileNames: ['真实文件名']
};
showImage('uploadFile1', data, {
showEdit: true, // 显示编辑按钮
showClear: true,
callback: function(data, id, name, uploader) {
layer.alert('编辑成功回调');
}
});
//上传图片控件
showImage('uploadFile2', null, {
showDel: true,
// editable:false,
fileMulti: true,
editable: true,
max: 3
});
//上传文件
fileUpload({
uploadId: 'uploadifyText',//组件id
fileType: 'doc',// 文件类型
fileExt: '.txt',// 目前不支持txt文件类型
callback: function(data, id, name, uploader) {
var imagePath = data.filePaths[0];
var realName = data.originalFileNames[0];
var inputText = $('#uploadifyText').closest('.file-upload-wrap').find('input:text');
inputText.val(realName);
inputText.attr('filePath', imagePath);
}
});
//上传文件
fileUpload({
uploadId: $('#uploadButton'),//组件id
fileType: 'doc',//文件类型
callback: function(data, id, name, uploader) {
var imagePath = data.filePaths[0];
var realName = data.originalFileNames[0];
var inputText = $('#uploadifyText').closest('.file-upload-wrap').find('input:text');
inputText.val(realName);
inputText.attr('filePath', imagePath);
}
});
});
</script>
</body>
</html>