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);
}
}
} 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);
}
}
}
你使用 send 发送 formdata 的时候不需要在设置 form-data 的头了,设置了反而有问题。
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号