I am developing an Angular6 web-application in which user selects an Excel file and import it into a web grid. Excel has a file column. I need to validate, the file exists on user's machine. I have written the following function.
import { HttpClient } from '@angular/common/http';
import { Observable, throwError, of } from 'rxjs';
import { catchError, tap, map } from 'rxjs/operators';
fileExists(path: string): Observable<boolean> {
return this.http.head(path).pipe(
map(response => {
return true;
}),
catchError(error => {
return of(false);
})
);
}
This http HEAD call is always being blocked by the browser, I have also tried with http GET but didn't work. I am getting the following error on Chrome 84.
Not allowed to load local resource: file///C:Users/username/file.txt