1

I'm working on an AngularJS application. There is a form where the user can input a path into a textbox.

<div class="form-group">
    <label for="source_path">Source Path:</label>
    <input type="text" class="form-control" id="source_path" ng-model="jobs.source_path" required>
</div>

At the moment, this requires the user to open a file browser on their local machine, navigate to the directory on the server, and paste that file path into the text box. I would like to make this a bit more user friendly by adding a Browse button that allows them to browse to the directory and select it, populating the text box, without having to copy and paste.


I cannot seem to find a way to allow the user to select the directory path. Everything I've been finding is for uploading a specific file. Is this possible? Or is there a better way to do this?

Sara Tibbetts
  • 4,408
  • 6
  • 35
  • 69
  • You have to use file type for input to achieve this. https://jsfiddle.net/oghjx62w/2/ – Vivz Jul 26 '17 at 13:39
  • @Vivz I need the file to not be uploaded though – Sara Tibbetts Jul 26 '17 at 13:46
  • Maybe something like this will suffice https://jsfiddle.net/oghjx62w/3/ ? – Vivz Jul 26 '17 at 13:51
  • @Vivz I think it might actually not be possible. https://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav Looks like browsers prevent it from being possible – Sara Tibbetts Jul 26 '17 at 14:14
  • 1
    So basically you can only show the file name but not the full path. The above method will only work for filename. – Vivz Jul 26 '17 at 14:17

1 Answers1

0

It is currently not possible. For security reasons, browsers will not allow access to the full path of a file.

Sara Tibbetts
  • 4,408
  • 6
  • 35
  • 69