2 Star 12 Fork 3

zxj/BeUpload

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

:airplane: 2024年5月27日16:27:31 还活着

示例地址

https://zhang_xing_ju.gitee.io/be-upload/index.html

使用说明

//查询文件详情
@PostMapping("/findFileById")
@ResponseBody
public ResponseEntity findFileById(@RequestBody String[] ids) {
    List<File> files = fileService.queryForList(ids);
    return ResponseEntity.ok(files);
}

//文件上传
@PostMapping({"/upload"})
public ResponseEntity<File> upload(@RequestParam MultipartFile file) {
    return ResponseEntity.ok(ileService.upload(file));
}


//文件下载
@GetMapping({"/download"})
public ResponseEntity<Void> download(String fileId) throws Exception {
 
}
  1. 修改文件相关的后台接口地址 common.js
let global = {
    //上传文件地址
    uploadUrl: "/file/upload",
    //下载文件地址
    downLoadUrl: "/file/download?id=",
    //查询文件的详情信息
    findFileByIdUrl: "/file/findById"
}

2.引入相关的css js

<link href="be-upload/common/common.css" rel="stylesheet">
    <script src="be-upload/common/common.js"></script>
  1. 像layui的其他组件一样使用即可
layui.use(['BeImgUpload'], function () {
    let beImgUpload = layui.BeImgUpload;

    //图片上传,会把图片的id通过逗号拼接成字符串,保存时通过name属性发送
    beImgUpload.render({
        id: "#imgupload",
        name: "imgIds",
        num: 5,   //图片数量限制
        size: 10, //10M, 大小限制
        readonly: false, //非只读
        type: ".png,.jpg,.jpeg",
        value: ['fileId1', 'fileId2']   //图片初始化,是图片id可以是数组,也可以是以,拼接的字符串
    });
})

使用示例 见下方代码

file-upload-demo.html img-upload-demo.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文件上传示例</title>
    <!-- 引入 layui.css -->
    <link href="./layui/css/layui.css" rel="stylesheet">
    <link href="be-upload/common/common.css" rel="stylesheet">
</head>
<body>
<div id="fileupload"></div>
</body>
<!-- 引入 layui.js -->
<script src="./layui/layui.js"></script>
<script src="be-upload/common/common.js"></script>
<script>
    layui.use(['BeImgUpload'], function () {
        let beImgUpload = layui.BeImgUpload;

        //图片上传,会把图片的id通过逗号拼接成字符串,保存时通过name属性发送
        beImgUpload.render({
            id: "#imgupload",
            name: "imgIds",
            num: 5,   //图片数量限制
            size: 10, //10M, 大小限制
            readonly: false, //非只读
            type: ".png,.jpg,.jpeg",
            value: ['fileId1', 'fileId2']   //图片初始化,是图片id可以是数组,也可以是以,拼接的字符串
        });
    })
</script>
</html>

效果图

img.png img_1.png img_2.png

MIT License Copyright (c) 2023 zxj Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于layui实现的上传组件,实现上传附件数量、类型、大小、回显、删除、放大、只读的功能 展开 收起
JavaScript 等 3 种语言
MIT
取消

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/zhang_xing_ju/be-upload.git
git@gitee.com:zhang_xing_ju/be-upload.git
zhang_xing_ju
be-upload
BeUpload
master

搜索帮助

Cb406eda 1850385 E526c682 1850385