Vue then use the file upload function; originally a small thing; if we use online components, they would be wasteful,
But then upload files using formdata when the error occurs; if the append method formdata, the required fields and then merge files together, you can not get back to other fields outside the file; upload failed due;
Solution: formdata only to save the file; not append other parameters; other parameters suffix to the rear url address; so you can avoid this problem
E.g:
var formData=new FormData(); formData.append('image',files[0]); formData.append('act',"upload_file"); capis.upLoadImgs(formData,header).then(data=>{ if(data.status=='success'){ this.upLoadImgsList.push(data.res[1]); if(this.subParms.attachments.length!=0){ this.subParms.attachments=this.subParms.attachments.split(','); } this.subParms.attachments.push(data.res[0]); this.subParms.attachments= this.subParms.attachments.join(','); this.$vux.toast.show({ text: '上传成功!', type:'success' }) }the else { the this . $ vux.toast.show ({ text: ' upload. Please try again! ' , type: ' The warn ' }) } .}) the catch (ERR => { the console.log ( ' Fail: ' + ERR); })