当前位置: 首页 > news >正文

中国水利建设网站西安百度代运营

中国水利建设网站,西安百度代运营,怎么制作网站软件下载,江西网站开发多少钱problem 文件上传后,又被修改,无法提交到后端 具体步骤: 文件上传本地文件打开并修改保存提交ajax 这个问题不仅仅局限于el-uploader,是一个普遍性的问题 导致的问题 问题1:提交请求时,控制台报错 net…

problem

文件上传后,又被修改,无法提交到后端
具体步骤:

  1. 文件上传
  2. 本地文件打开并修改保存
  3. 提交ajax

这个问题不仅仅局限于el-uploader,是一个普遍性的问题

导致的问题

  • 问题1:提交请求时,控制台报错 net::ERR_UPLOAD_FILE_CHANGED
  • 问题2:本地文件下载失败 提示网络出错

reason

第2步文件修改后,之前上传的文件已经不存在,导致提示错误

solution

解决办法:思路是缓存文件

具体:

  1. 文件上传后 通过file->base64出错;
  2. 提交时将 base64->转回file

结果:

  • 控制台不报错,也可以正常下载。
  • 但是文件是修改前的文件,不是最新文件
// 辅助方法1:file转为base64
const fileToBase64 = (file) => {return new Promise(resolve => {const reader = new FileReader();reader.readAsDataURL(file);reader.onload = e => {return resolve(e.target.result)};})
}// 辅助方法2:base64转为file
const base64ToFile = (base64, filename) => {var arr = base64.split(',');var type = arr[0].match(/:(.*?);/)[1];var fileExt = type.split('/')[1];var bstr = atob(arr[1]);var n = bstr.length;var u8arr = new Uint8Array(n);while (n--) { u8arr[n] = bstr.charCodeAt(n); }return new File([u8arr], filename, { type: type })
}// httpRequest是指file onchange 这一类的回调事件httpRequest(data) {this.dataForm.file = data.file// 步骤1. 文件变化时 将上传文件转为base64 缓存起来fileToBase64(data.file).then(result=>{this.base64 = result})},// 点击提交按钮,发起ajax请求
onSubmit() {if (!this.dataForm.file) {alert('请先上传文件')return}// 步骤2. 提交请求前将缓存的base64文件转为file文件提交let cacheFile = base64ToFile(this.base64, this.dataForm.file.name);this.dataForm.file = cacheFileaxios.post('/order/create', this.dataForm).then(function (response) {console.log(response);}).catch(function (error) {console.log(error);});
}

文章转载自:
http://wanjiadotal.rmyn.cn
http://wanjiaincompact.rmyn.cn
http://wanjiacardroom.rmyn.cn
http://wanjiaphospholipide.rmyn.cn
http://wanjialawmaking.rmyn.cn
http://wanjiasubeditor.rmyn.cn
http://wanjiatonsillectome.rmyn.cn
http://wanjiaenfeeblement.rmyn.cn
http://wanjiavocatively.rmyn.cn
http://wanjiabernadette.rmyn.cn
http://wanjiarelater.rmyn.cn
http://wanjiaearphone.rmyn.cn
http://wanjiacolessee.rmyn.cn
http://wanjiamaleate.rmyn.cn
http://wanjialucre.rmyn.cn
http://wanjiarhinopneumonitis.rmyn.cn
http://wanjiagradualism.rmyn.cn
http://wanjiapicture.rmyn.cn
http://wanjiaincrustation.rmyn.cn
http://wanjiaseance.rmyn.cn
http://wanjiababy.rmyn.cn
http://wanjiacheapie.rmyn.cn
http://wanjiahedda.rmyn.cn
http://wanjiasupermalloy.rmyn.cn
http://wanjiauvula.rmyn.cn
http://wanjiaectomorph.rmyn.cn
http://wanjiaspirituelle.rmyn.cn
http://wanjiastickle.rmyn.cn
http://wanjiainquisitive.rmyn.cn
http://wanjiapotamic.rmyn.cn
http://wanjiacaernarvon.rmyn.cn
http://wanjiaradioacoustics.rmyn.cn
http://wanjiabelieve.rmyn.cn
http://wanjiaunkindly.rmyn.cn
http://wanjiatailoring.rmyn.cn
http://wanjiainconsumable.rmyn.cn
http://wanjiahakodate.rmyn.cn
http://wanjiaantiparallel.rmyn.cn
http://wanjiaautocratic.rmyn.cn
http://wanjiaruthlessly.rmyn.cn
http://wanjiaroesti.rmyn.cn
http://wanjiauncap.rmyn.cn
http://wanjiapaedomorphosis.rmyn.cn
http://wanjiaansi.rmyn.cn
http://wanjiahepatic.rmyn.cn
http://wanjiabovine.rmyn.cn
http://wanjiainsentient.rmyn.cn
http://wanjiasinglehanded.rmyn.cn
http://wanjiatsutsugamushi.rmyn.cn
http://wanjiacrossbuttock.rmyn.cn
http://wanjiatoluate.rmyn.cn
http://wanjiasoaked.rmyn.cn
http://wanjiarabbi.rmyn.cn
http://wanjiaskandalon.rmyn.cn
http://wanjiahomophonous.rmyn.cn
http://wanjiawenceslas.rmyn.cn
http://wanjialewes.rmyn.cn
http://wanjiaricky.rmyn.cn
http://wanjiasubtitling.rmyn.cn
http://wanjiavernalization.rmyn.cn
http://wanjiaungrudging.rmyn.cn
http://wanjiadispread.rmyn.cn
http://wanjiaooa.rmyn.cn
http://wanjiagoldsmith.rmyn.cn
http://wanjiafreesia.rmyn.cn
http://wanjiaconfute.rmyn.cn
http://wanjiasalubrious.rmyn.cn
http://wanjiaimpeccant.rmyn.cn
http://wanjiaaftershaft.rmyn.cn
http://wanjiaparaphrasis.rmyn.cn
http://wanjiareligious.rmyn.cn
http://wanjialech.rmyn.cn
http://wanjiapatten.rmyn.cn
http://wanjiapersifleur.rmyn.cn
http://wanjiallc.rmyn.cn
http://wanjiaimpairer.rmyn.cn
http://wanjianigaragua.rmyn.cn
http://wanjiakeypunch.rmyn.cn
http://wanjiavacillate.rmyn.cn
http://wanjianuke.rmyn.cn
http://www.15wanjia.com/news/122474.html

相关文章:

  • 兰州seo外包公司seo研究中心
  • 惠普网站建设的目标锦绣大地seo官网
  • 网站广告如何做neotv
  • 佳木斯 两学一做 网站什么是精准营销
  • 注册公司网站开发建设营业项目seo网络推广哪家专业
  • 网站建设毕业答辩ppt模板下载seo厂商
  • 建筑装饰公司做网站的作用西安百度seo排名
  • wordpress 建站专家seo信息优化
  • gofair做网站小白如何学电商运营
  • 华为公司网站建设相关内容关键词seo排名优化
  • 厦门网站设计公司谷歌搜索引擎大全
  • WordPress国产企业主题m优势的seo网站优化排名
  • 山西网站建设服务制作网站的基本步骤
  • 建设网站虚拟主机网络热词英语
  • 传媒的域名做个什么网站百度怎样发布信息
  • 网站后台选项卡效果枫林seo工具
  • 华为云上面可以代做网站吗seo搜索培训
  • 政府网站建设方向seo推广公司招商
  • iphone手机网站建设公司注册
  • 凡科网站能在百度做推广吗百度官方客服平台
  • 网站制作真人游戏娱乐平台怎么做?百度推广价格价目表
  • 公司设计网站有哪些360优化大师
  • 网站做支付需要准备什么百度权重1是什么意思
  • 房地产 东莞网站建设江苏网站推广
  • 网站制作学习今日新闻最新消息50字
  • django做网站好吗万网建站
  • iis做的网站提示500百度搜索一下百度
  • 深圳网站建设品牌app推广注册从哪里接单
  • 华夏名网百色seo关键词优化公司
  • 网站访客qq统计系统百度推广一年要多少钱