I am new to JavaScript hence all mess up with me this time.my doubt is I want to create a JavaScript function which can get the names of all the files in a folder.
Please share your knowledge to get me the basic understanding for this.
I am new to JavaScript hence all mess up with me this time.my doubt is I want to create a JavaScript function which can get the names of all the files in a folder.
Please share your knowledge to get me the basic understanding for this.
Because of security, generally you cannot access local files, but in modern browsers you can access some limited files in the sandbox. Your question is completely answered here: local-file-access-with-javascript
HTML:
<input type="file" id="files" name="files[]" multiple="" webkitdirectory="">
JS (modern browsers only):
var getFileNames=function(selectorForInput){
var files=[].reduce.call(document.querySelector(selectorForInput).files,function(files,file){
files.push(file.name);
return files;
},[]);
return files;
};
getFileNames('#files');