I used this library to download the angular2 file https://github.com/valor-software/ng2-file-upload
Now I get this error when uploading a file
XMLHttpRequest cannot load http: // localhost: 8080 / files . The response to the preliminary check request does not pass the access control check: the value of the "Access-Control-Allow-Origin" header in the response should not be a wildcard "*" if the request credential mode is set to include. Therefore, the origin of ' http: // localhost: 3000 ' is not allowed. XMLHttpRequest-initiated request credential mode is controlled by the withCredentials attribute.
Do withCredentials = falsebefore loading the item. You can put this code in ngOnInit/ constructoror ngOnChanges.
withCredentials = false
ngOnInit
constructor
ngOnChanges
this.uploader.onBeforeUploadItem = (item) => { item.withCredentials = false; }
Responds to your server CORS Header
CORS Header
'Access-Control-Allow-Credentials' = true
This is the security provided CORS, you are not allowed to do this. You cannot use Access-Control-Allow-Origin= * if you want to allow credentials. You will need to specify the exact domain. try to specify
CORS
Access-Control-Allow-Origin
localhost:<portnumber>
See the following links for more information.
:
ngAfterViewInit() { this.uploader.onAfterAddingFile = (item => { item.withCredentials = false; }); }
Source: https://habr.com/ru/post/1670059/More articles:I am trying to get JSON data from js and get null in an action class - jsonHow to send Json to Struts2? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1670056/how-to-pass-multiple-checkboxes-to-the-action&usg=ALkJrhg9outodmtWBbutgGZBYdRDZV7MfAApplication Indexing: We Can't Find APK App for Android - AndroidUnable to bring md button to front in md-tabs - angularjsUnderstanding Parallel.Invoke, Creating and Reusing Threads - multithreadingHow to display svg icons (.svg files) in user interface using React Component? - reactjsExport asp core core to Excel - excelAccra Value Classes - scalaException handling in the anti-corruption layer (ACL) - exception-handlingAll Articles