解决IE和edge图片上传问题

const agent = window.navigator.userAgent
const isEdge = agent.indexOf('Edge') > -1
let files = {}
// 非Edge下上传
if (!isEdge) {
    files = new window.File(
        [data],
        this.options.name,
         { type: data.type }
      )
} else {
    files = new Blob([data], { type: data.type })
}
const myFormData = new FormData() // 根据获取到的form节点创建formData对象
 
myFormData.append('file', files, this.options.name) // 后台即可根据此name捕获到前台发送的数据或文件

 作者:隋元超

猜你喜欢

转载自blog.csdn.net/m0_46573967/article/details/112466359