0

I am using angular2-image-upload module for upload my image in my project and I used this code:

 <image-upload
  [max]="100"
  [url]="'example.com/images/upload'"
  [headers]="{header: 'Authorization', value: 'MyToken'}"
  [buttonCaption]="'Select Images!'"
  [dropBoxMessage]="'Drop your images here!'"
  [extensions]="['jpg','png','gif']"
  (onFileUploadFinish)="imageUploaded($event)"
  (onRemove)="imageRemoved($event)"
  (isPending)="disableSendButton($event)"
></image-upload>

but I get below error :

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

and in the end , the image is uploded (status code : 200 in network tab in chrome browser) but I don't recieve any response from server.

How can I solved this problem?

mosi
  • 39
  • 9
  • This is pretty likely to need a server side fix as it looks like CORS (not a problem with your Angular code). You can read more about it [in this question](https://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource) – 0mpurdy Aug 05 '17 at 12:08
  • Possible duplicate of ["No 'Access-Control-Allow-Origin' header is present on the requested resource"](https://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource) – 0mpurdy Aug 06 '17 at 07:46

0 Answers0