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
|
$("#file-input").fileinput({
uploadUrl: "/file",
uploadAsync: true,
maxFileCount: 100,
previewFileType: ['image', 'html', 'text', 'video', 'audio', 'flash'],
uploadExtraData: function () {
return {
categoryId: $("#category-id").val(),
tag: $("#tag").val(),
description: $("#description").val(),
prefix: getQuery("prefix")
};
},
maxFilePreviewSize: 51200
}).on('fileuploaded', function (event, data, previewId, index) {
var json = data.response;
if (json.status === "success") {
alerts("上传成功");
} else {
alerts("上传失败,文件不合法");
}
});
$(document).on('ready', function () {
$("#file-input").fileinput({
maxFilePreviewSize: 10240
});
});
$.get("/category/all", function (data) {
var json = JSON.parse(data);
var option = "";
$.each(json, function (i, category) {
option += "<option value='" + category.id + "'>" + category.name + "</option>";
});
if (!isEmpty(option)) {
$("#category-id").html(option);
}
});
|