首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >元素ui上传组件不发送流数据

元素ui上传组件不发送流数据
EN

Stack Overflow用户
提问于 2018-07-24 11:29:52
回答 2查看 3.1K关注 0票数 0

使用el-上载组件的图像上传

我没有从服务器获得204条内容响应。

代码语言:javascript
运行
复制
   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",
      )

对服务器的请求没有图像数据。

如何让组件发送图像数据?

EN

回答 2

Stack Overflow用户

发布于 2018-07-30 12:47:00

我也遇到了一个类似的问题,我使用表单数据来解决这个问题。我将自动上传属性设置为false,然后传递自定义http请求。

代码语言:javascript
运行
复制
<el-upload  drag action="" :data="fileList"   :http-request="uploadFiles" :auto-upload="false" :multiple="false" >

在上传文件的自定义函数中,我创建了一个新的formData对象,并在上传到服务器之前对其进行处理。下面是一个例子

代码语言:javascript
运行
复制
    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);
   },
票数 0
EN

Stack Overflow用户

发布于 2022-02-23 03:08:22

代码语言:javascript
运行
复制
 handleChange(file, fileList){
                    this.fileList.push(file);
                },
代码语言:javascript
运行
复制
:on-change="handleChange"
:file-list="ListFiles"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51497475

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档