关于EL-UPLOAD详细

详细说明:

<el-upload drag multiple
 name="multipartfiles" //后台接收文件流的参数名
 ref="upload"
 :limit="limit"  //限制文件数量
 :action="imageAction" //上传图片的访问的服务器路径
 :data="uploadData" //需要携带的其他参数
 :on-preview="handlePreview" //点击时触发的事件
 :on-remove="handleRemove" //点击移除文件时触发的事件
 :file-list="fileList" //已上传的文件list
 :beforeUpload="beforeAVatarUpload" //上传之前触发的事件,我在这里做了上传文件的类型控制
 :on-exceed = "onExceed" //和limit一起用 当文件数量超出限制时触发
 :onError="uploadError" //上传失败时触发
 :onSuccess="uploadSuccess" //上传成功时触发
 :auto-upload="true"> //是否自动上传
 <i class="el-icon-upload"></i>
 <div class="el-upload__text">将图片拖到此处,或<em>点击上传</em></div>
 <div class="el-upload__tip" slot="tip">只能上传'jpg/png/jpeg/gif'</div>
</el-upload>


后端

     @RequestMapping("/save")
        public String save(@RequestParam("fileList") MultipartFile[] multipartfiles) throws IOException {
            //遍历文件
            if(multipartfiles != null && multipartfiles.length>0){
                for(MultipartFile item : multipartfiles){
                    String fileName = item.getOriginalFilename();//获取文件名
                    String filePath =upload_folder;// Path + "uploadFiles/uploadFiles";//自定义上传路径
                    File file = new File(filePath,fileName);
                    if(!file.exists()){//判断文件夹是否存在,如果不存在则创建
                        if(!file.getParentFile().exists()){
                            file.getParentFile().mkdirs();
                        }
                        file.createNewFile();
                    }
                    item.transferTo(file);//上传文件
                }
            }

            return "R.ok()";
        }

1、vue+springBoot element-ui upload组件

参考文章:https://blog.csdn.net/qq_39774931/article/details/81773706

2、限制UPLOAD功能

参考文章:https://blog.csdn.net/qq_21423689/article/details/78803701

参考文章:https://segmentfault.com/a/1190000013796215

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值