我正在尝试使用我的 chrome 扩展程序进行发布。这是我正在使用的方法。
function uploadFile(url){
var req = new XMLHTTPRequest();
req.open("POST", "https://wepicit.s3.amazonaws.com/", true);
var params = "key="+myKey
"&acl="+"public-read"
"&Content-Type="+"text/plain"
"&AWSAccessKeyId"+tempKey
"&file="+url+".txt"
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", params.length);
req.setRequestHeader("Connection", "close");
req.send(params);
req.onreadystatechange = function(){
// If the request completed, close the extension popup
if (req.readyState == 4)
if (req.status == 200) console.log('success');
};
}
我得到的错误是未定义“XMLHTTPRequest()”。请帮忙。谢谢你。