|
我通过var pic=canvas.toDataURL() 获取了一个 Base64 图片
我现在需要post 到一个服务器上去,给定了一个url,服务器做了Response.AppendHeader("Access-Control-Allow-Origin", "*"); 处理
现在总是报:XMLHttpRequest cannot load Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
代码如下
function putb64(pic,url){
var xhr = new XMLHttpRequest();
var xhrget = new XMLHttpRequest();
var obj;
xhr.onreadystatechange=function(){
if (xhr.readyState==4){
//document.getElementById("myDiv").innerHTML=xhr.responseText;
alert(xhr.responseText);
}
}
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/octet-stream");
xhr.send(pic);
} |
|