1

In my angular mvc project, user has to select the folder where he wants to download the files from server. Following are my code in html section :

 <input type="file" id="filepicker" name="fileList" (change)="filesPicked($event)" webkitdirectory mozdirectory msdirectory odirectory directory multiple  />

In my ts file:

 filesPicked(e: any) {
    var files = e.target.files;
    var path = files[0].webkitRelativePath;
    var Folder = path.split("/");
    console.log(Folder)
    alert(Folder[0]);
}

My problem is I am not getting total path like D:\projects\myproject.

Why I need this - I need to send this to server.directory chooser not getting path. When user clicked on above download button, file will be downloaded at provided user specified location.

Amitesh Bharti
  • 14,264
  • 6
  • 62
  • 62
paruvelly Vishwanath
  • 1,202
  • 3
  • 14
  • 30

1 Answers1

0

That is not possible to get information about the user's filesystem as this poses security risks.

This scenario has already been discussed earlier in following threads :

Get browser download path with javascript

Download A File At Different Location Using HTML5

Most OSs tend to just default to a Download location and this is something the user decides through the Browser they use. Not the website. Browsers are deliberately isolated from the local filesystem in order to prevent scripting attacks.

Amitesh Bharti
  • 14,264
  • 6
  • 62
  • 62