Home > front end >  Ajax for web documents
Ajax for web documents

Time:01-12

The function getBase64 (imgUrl) {
Window. The URL=window. URL | | window. WebkitURL;
var xhr=new XMLHttpRequest();
XHR. Open (" get ", imgUrl, true);
//vital
XHR. ResponseType="blob";
XHR. onl oad=function () {
If (this. Status==200) {
//get a blob object
var blob=this.response;
//the console. The log (" blob "blob);
//vital
Let oFileReader=new FileReader ();
OFileReader. onl oadend=function (e) {
//to get here is the picture of base64
Let base64=e. arget. Result;
Base64="& lt; P id="' Base64Text '& gt;" + base64 + "& lt;/p> ";
Document. The getElementsByTagName (" body ") [0]. InnerHTML=base64;
Return base64.
};
OFileReader. ReadAsDataURL (blob);
}
}
xhr.send();
}

I find such a JS code on the Internet, you can get the network file base64, can at first, but then don't know what is the limit, web developers do to can not get, is there any way to break through?

CodePudding user response:

Should set up a cross-domain request that the feeling is prohibited

CodePudding user response:

reference 1st floor chenrynet response:
should be set to ban cross-domain request the populace
what have other way to use js to download network file, you can just get, either binary or base64
  • Related