使用el-上载组件的图像上传
我没有从服务器获得204条内容响应。
el-upload(
action="https://s3-us-west-1.amazonaws.com/stage.greenausm.com",
:mulitple="false",
:data="xhrData"
:show-file-list="false", :on-success="handleAvatarSuccess",
:before-upload="beforeAvatarUpload",
)
对服务器的请求没有图像数据。
如何让组件发送图像数据?
发布于 2018-07-30 12:47:00
我也遇到了一个类似的问题,我使用表单数据来解决这个问题。我将自动上传属性设置为false,然后传递自定义http请求。
<el-upload drag action="" :data="fileList" :http-request="uploadFiles" :auto-upload="false" :multiple="false" >
在上传文件的自定义函数中,我创建了一个新的formData对象,并在上传到服务器之前对其进行处理。下面是一个例子
uploadFiles() {
//Create new formData object
const fd = new FormData();
//append the file you want to upload
fd.append("file", this.file.raw);
//add other data to the form data object if needed
fd.append("data", this.data);
//send call the api to upload files using axios or any other means
axios.post('http://serveUrl/upload', fd);
},
发布于 2022-02-23 03:08:22
handleChange(file, fileList){
this.fileList.push(file);
},
:on-change="handleChange"
:file-list="ListFiles"
https://stackoverflow.com/questions/51497475
复制相似问题