formdata.append('images',type);   var xhr=new XMLHttpRequest();       xhr.open('post',path,true);     // xhr.setRequestHeader('content-type','multipart/form-data'); 若这儿一旦设置就会上传失败,这是怎么回事?难道是类型设置错误?       xhr.send(formdata);       xhr.onreadystatechange=function(){         if (this.readyState===4 && this.status===200)          {            if (this.responseText)             {              var data=this.responseText;              console.log(this.responseText);             }          }       }
 
 
Reply content:
 
   formdata.append('images',type);   var xhr=new XMLHttpRequest();       xhr.open('post',path,true);     // xhr.setRequestHeader('content-type','multipart/form-data'); 若这儿一旦设置就会上传失败,这是怎么回事?难道是类型设置错误?       xhr.send(formdata);       xhr.onreadystatechange=function(){         if (this.readyState===4 && this.status===200)          {            if (this.responseText)             {              var data=this.responseText;              console.log(this.responseText);             }          }       }
 
 
You send formdata do not need to set the header when you use the Send form-data , set up the problem instead.