0
我能夠通過郵遞員,甚至通過我的應用程序時,我用這樣簡單的JavaScript請求來發布基地64編碼的圖像:NG-文件上傳跨域錯誤
var data= "userPhoto=data%3Aimage%2Fjpeg%3Bbase64%2C%2F9j%2F4AAQSkZJRgABAQEAS ................(image data) Rd1bbfc2B%2FdDXGWxWHtA2N6NrL%2BLNf6wIa92a5m5v2s0c7tObhgdJMdV6Rm4mt7YkqukTMsv2vVsgl5j73tQasFOHYMP3nqf%2F%2FZ";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://localhost:8000/test2");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("postman-token", "b98cbdf1-8918-b8fb-6b50- a626c301cffc");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.send(data);
但是,當我使用簡單
<div class="button" ngf-select ng-model="file" name="file" ngf-pattern="'image/*'" ngf-accept="'image/*'" ngf-max-size="20MB" ngf-min-height="100" ngf-resize="{width: 100, height: 100}">Select</div>
腳本:
代碼 ng-file-uploadHTML複製210
我得到一個跨域錯誤:
XMLHttpRequest cannot load 'url'. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
基本上我試圖從開始實際場景的簡化版本到最基本的使用情況下,網站上的所有不同的組合。它只是我或角度錯誤真的令人沮喪,因爲它們之間有很多層。 C#絕對不是那麼難