赞
踩
文件上传下载实现流程:后台手册 | RuoYi
1、前端就是给了个按钮,点一下就开始文件上传了。但是在点击开始长传之前要通过前端对上传的文件的类型(因为照片都是jpg、png)的进行一个预先判断:
- // 上传预处理
- beforeUpload(file) {
- if (file.type.indexOf("image/") == -1) {
- this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
- } else {
- const reader = new FileReader();
- reader.readAsDataURL(file);
- reader.onload = () => {
- this.options.img = reader.result;
- };
- }
- },
2、然后开始上传走到后端来,运行核心方法:com.ruoyi.web.controller.system.SysProfileController
- /**
- * 头像上传
- */
- @Log(title = "用户头像",
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。