前端上传文件到后端原理:使用Element + vue
使用Element 中的uoload 在:action中是后端服务器接收上传文件的接口
:action=this.baseUrlApi+'sound-record/insert'
在上传成功后会通过 :on-success="onSuccess" 方法接收服务器回传的刚才保存的文件的物理地址
<el-upload :headers="uploadHeaders" :action="baseUrlApi+'prisoners/import'" :data="datas" :disabled="daoru" :on-success="onSuccess" :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" name="annexFile" accept=".mp3, .CRT,.png"> <el-button size="small" type="primary">点击上传</el-button> <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> </el-upload>