Not getting correct path of file in Angular

Viewed 155

I am new to Angular . When the user uploads a file, I want to get the file location . But I am getting a path value like this (The actual location is D:\Games\example.docx):

C:\fakepath\example.docx

The below is my code:

 onFileSelected(event){
    
    console.log(event);
    this.selectedFile= <File>event.target.files[0];
    console.log(event.target.value);

    
    this.addSftpModel.selectedFile=this.selectedFile;
    
    
  }

How can I get the original location of file uploaded

2 Answers

You can't get the full path of the file through a browser application. If you could, you could do whatever you want on the filesystem of the client, so it's normal that it's not accessible.

I don't know why you need the real path, but if you only need the file, the fakepath do the job.

No, you can't get a full path of the input type=file because it will create a vulnerability. You can read here for more detail.

Related