Is there a way to get the file path of the file that the user has uploaded?
I have this input field (Angular):
<div class="input-group mb-3">
<input #select type="file" class="form-control" id="inputGroupFile02" (change)="readFile(select)" accept=".txt">
<label class="input-group-text" for="inputGroupFile02">Upload</label>
</div>
I'm able to get the file name and its content this way:
async readFile(select: HTMLInputElement) {
this.fileToUpload = select?.files?.item(0) || null;
const formData: FormData = new FormData();
if (this.fileToUpload) {
formData.set("name", this.fileToUpload.name);
formData.set("file", await this.fileToUpload.text().then(fileContent => {
return fileContent
}));
}
Is there a way I can get the file path so that i can store it in a database? I could only manage to get "fakepath/fileName" and I know that this is done for security reason, but there's a secure way to get the path? (Maybe with some NodeJS API?! I tried to see if I could do it using the fs module but i didn't find anything useful). Thank you.