diff options
| author | zhanghongqing <[email protected]> | 2022-08-09 16:54:16 +0800 |
|---|---|---|
| committer | zhanghongqing <[email protected]> | 2022-08-09 16:54:16 +0800 |
| commit | b3fa11d4b1b5a68d7b04fde5eb6cfbda557927eb (patch) | |
| tree | a49d344e49fc427fbf4cf00aa4963c4d04cd98a4 /src/main/resources/assets/js/upload.js | |
| parent | d8a2be0d094ac9ba2d47c81ebf03b3fe6e34a078 (diff) | |
Diffstat (limited to 'src/main/resources/assets/js/upload.js')
| -rw-r--r-- | src/main/resources/assets/js/upload.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/resources/assets/js/upload.js b/src/main/resources/assets/js/upload.js new file mode 100644 index 0000000..cc8051a --- /dev/null +++ b/src/main/resources/assets/js/upload.js @@ -0,0 +1,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); + } +});
\ No newline at end of file |
