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>