前端将获取到的文件列表中的originFileObj
上传到后端,后端通过MultipartHttpServletRequest
接受即可
贴代码如下:
<template>
<Profile :selectedKeys="thisSelectedKeys" :open-keys="thisOpenKeys">
<template v-slot:content>
<a-row>
<a-col :span="24" :style="{ marginTop: '36px' }"> </a-col>
<a-col :span="18" :offset="3">
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item label="选择文件" prop="file" ref="file">
<a-upload-dragger
:before-upload="beforeUpload"
name="file"
:file-list="form.file"
action="/api/user/uploadfile"
@change="handleChange"
:preview-file="previewFile"
>
<p class="ant-upload-drag-icon">
<a-icon type="inbox" />
</p>
<p class="ant-upload-text">点击或拖拽上传文件</p>
<p class="ant-upload-hint">
仅可选择单个文件
</p>
</a