vue获取文件流上传文件
重点:
const formData = new FormData();
formData.append("file",this.file.raw)
<el-upload
class="upload-demo"
ref="upload"
action="#"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-change="onChange"
:limit="1"
:on-exceed="handleExceed"
:auto-upload="false"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip" style="margin-left: 10px">只能上传<span
style="color: #007fb3">xlsx/xls/et</span>文件,且不超过<span style="color: #007fb3">10M</span></div>
</el-upload>
submitUpload() {
const formData = new FormData();
formData.append("file",this.file.raw)
console.log(this.file)
console.log("上传事件")
importExcel(formData).then(data => {
// this.$notify.success('修改成功')
// this.visible = false
// this.$emit('refreshDataList')
console.log(data)
console.log(66666)
}).catch(() => {
this.canSubmit = true;
});
// this.$refs.upload.submit();
},
@PostMapping("/importExcel")
public R importExcel(@RequestBody BigdataStudents bigdataStudents, @RequestPart("file") MultipartFile file) {
// System.out.println(bigdataStudents);
System.out.println(file);
System.out.println(bigdataStudents);
return R.ok(null);
}
版权声明:本文为qq_41820986原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。