在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 前端上傳圖片,后臺識別不到file對象

前端上傳圖片,后臺識別不到file對象

前端上傳圖片file對象什么的都可以打印出來,但是后臺就是識別不到file對象
上傳圖片的代碼如下

<template>
  <div class="upload">
    <div class="upload_warp_upload">
        <span v-for="(item,index) of imgList" class="upload_span">
           <img :src="item.url">
            <span @click="fileDel(index)" class="upload_del"></span>
        </span>
        <div class="upload_warp_left" @click.stop="fileChange">
          <span>+</span>
        </div>
      </div>
      <input accept="image/*"
             @change.stop="fileChange($event)"
             type="file" id="upload_file" style="display: none"/>

    </div>
  </div>
</template>
<script>
  export default {
    data(){
      return {
        imgData:[],
        imgList: [],
        size: 0,
      }
    },
    methods:{
        fileClick() {
          document.getElementById('upload_file').click();
        },
        fileChange() {
            let reader = new FileReader();
            let file = e.path[0].files[0];
            reader.readAsDataURL(file);
            let that = this;
            reader.onloadend = function () {
              let url = reader.result;
              that.imgList.push({url: url, name :file.name});
              that.$messageBox('成功');
              that.imgData.push(file);
              that.$emit('imageListChange', that.imgData);
            };
        },
        fileDel(index) {
          this.imgList.splice(index, 1);
        },
      }
  }
</script>

前端打印出來的file對象
圖片描述

network中的數(shù)據(jù):
圖片描述

各位大神啊~這是咋回事啊,我已經(jīng)接近崩潰了

回答
編輯回答
失魂人

哈哈哈哈哈~~~ 打死后臺

2017年5月1日 06:32
編輯回答
互擼娃

得通過name屬性來獲取file對象把

2018年8月7日 00:52
編輯回答
耍太極

我也遇到這種情況,原因是webpack代理導致的,換成nginx就好了

2018年2月13日 09:39
編輯回答
別瞎鬧

我看你直接把file,push到imgData里面了。
每次上傳文件到后臺,我的做法是

var formData = new FormData();
formData.append('file' , files[i]);

然后ajax,直接把formData 傳給后臺,這樣后臺就可以識別file。

2017年5月22日 23:20