2

Let me start by stating that I do NOT want to upload a directory, rather I am trying to have the user simply browse to a particular directory and I need to extract that path for working on later. So far I have implemented the upload scenario, however that only gives me the filename due to the security during an upload.

I cannot seem to find a template or code for just a file / folder browser for selection, am I missing something or is the best I can achieve?

function selectFolder(e) {
  var theFiles = e.target.files;
  var relativePath = theFiles[0].webkitRelativePath;
  var folder = relativePath.split("/");
  window.alert(folder[0]);
}
<div class="file-upload" id='file-upload'>
  <div class="file-select">
    <div class="file-select-button" id="fileName">Choose File</div>
    <div class="file-select-name" id="noFile">No file chosen...</div> 
    <input type="file" id="FileUpload" onchange="selectFolder(event)" webkitdirectory />
  </div>
</div>
Dominique Fortin
  • 2,116
  • 11
  • 20
  • 1
    Does this answer your question? [How to get full path of selected file on change of using javascript, jquery-ajax?](https://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav) – Shlang Mar 29 '20 at 22:38

0 Answers0