Using Chrome's webkitdirectory property it's possible to open a folder browser dialog box and select a folder. My code below lists the contents of the selected folder, however, subfolders are returned as dots and all recursive files just return as part of a list. What I want to do is get a list of files including their path (as is possible when dragging & dropping using e.dataTransfer.items).
I know this is possible because Google Drive does it as well as another uploading website I have seen. I can't seem to find anything on the web to answer this question.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head></head>
<body>
<form>
<input type="file" value="Browser Folder" onChange="selectFolder(event)" webkitdirectory directory>
</form>
<script type="text/javascript">
function selectFolder(e) {
var theFiles = e.target.files;
for (var i=0, file; file=theFiles[i]; i++) {
document.write("<li>" + file.name);
}
}
</script>
</body>
</html>