How can I get the local path of the file from input in HTML?
By the code below I received
'C:\fakepath\fileTest.txt'
I need a local path to send to my controller in .netcore web API because I have to create a uploaded file on the backend.
My .ts
fileChanged(e) {
this.file = e.target.files[0];
console.log('name of file' + this.file.name); // name of file
console.log('path of file' + e.target.value); // path of file
}
uploadDocument(file) {
let fileReader = new FileReader();
fileReader.onload = (e) => {
console.log(fileReader.result);
};
fileReader.readAsText(file);
console.log('sadasdas' + file);
}
My .html
<div class="col-md-6">
<p class="my-0">Attachements</p>
<input type="file" (change)="fileChanged($event)" class="btn btn-secondary" appBootstrapErrors [formControlName]="formControlNames.ATTACHEMENTS">
</div>