이미지 업로드를 위해 ng-file-upload을 사용하여 이미지 파일을 업로드합니다. 주어진 예제를 사용하여 액세스 제어 헤더 오류가 발생했습니다.ng-file-upload로 각도 파일 업로드
vm.uploadPic = function(file) {
file.upload = Upload.upload({
url: 'http://localhost:8000/api/v1/quotes/quoteitem/image/upload',
data: {quote_item_id: vm.quote_item_id, filename: file}
});
}
이 오류 그렇게 우체부에 이미지를 업로드하는 동안 어떤 헤더 요청이 필요하지 않습니다
XMLHttpRequest cannot load http://localhost:8000/api/v1/quotes/quoteitem/image/upload . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:3000 ' is therefore not allowed access.
를 제공, 나는 헤더를 제거했습니다.
vm.uploadPic = function(file) {
file.upload = Upload.upload({
url: domain+'/api/v1/quotes/quoteitem/image/upload',
data: {quote_item_id: vm.quote_item_id, filename: file},
transformRequest: function(data, headersGetter) {
var headers = headersGetter();
headers['Content-type']=undefined;
return headers;
}
});
}
이
TypeError: data.hasOwnProperty is not a function at ng-file-upload.js:310 at angular.js:10484 at forEach (angular.js:322) at transformData (angular.js:10483) at $get.serverRequest (angular.js:11211) at processQueue (angular.js:15961) at angular.js:15977 at Scope.$get.Scope.$eval (angular.js:17229) at Scope.$get.Scope.$digest (angular.js:17045) at Scope.$get.Scope.$apply (angular.js:17337)
내가 지금 꽤 시간이에 붙어 있습니다. 나는 서버 측에서 테스트를했고 우편 배달부에서 잘 작동한다. 어떤 도움이라도 훌륭합니다.
서버가 POST 및 옵션에 대한 CORS를 허용 할 필요가하려고 시도하십시오. 오류 메시지가 분명합니다. 브라우저의 네트워크 탭에서 서버의 응답 내용을보고 적절한 헤더와 함께 옵션 요청이 반환되는지 확인하십시오. – danial