[removed] Read files in folder

前端 未结 2 1121
借酒劲吻你
借酒劲吻你 2020-12-17 17:32

EDIT: I\'m trying to read all the files in a specific folder and list the files in there, not read the content of a specific file. I just tried to simply cr

相关标签:
2条回答
  • 2020-12-17 18:16

    The method I found with a Google search uses HTML5 so if you are using a modern browser you should be good. Also the tutorial page seems to check if the browser you are using supports the features. If so you should be good to follow the tutorial which seems pretty thorough.

    http://www.html5rocks.com/en/tutorials/file/dndfiles/

    0 讨论(0)
  • 2020-12-17 18:20

    This solution only works on IE11 or older since it is MS based

    <script type="text/javascript"> 
        var fso = new ActiveXObject("Scripting.FileSystemObject"); 
    
        function showFolderFileList(folderspec) {    
            var s = "";
            var f = fso.GetFolder(folderspec);
    
            // recurse subfolders
            var subfolders = new Enumerator(f.SubFolders);
            for(; !subfolders.atEnd(); subfolders.moveNext()) {
                s += ShowFolderFileList((subfolders.item()).path);
            }  
    
            // display all file path names.
            var fc = new Enumerator(f.files);
            for (; !fc.atEnd(); fc.moveNext()) {
                s += fc.item() + "<br>";
            }
            return s; 
        }
    
        function listFiles() {
            document.getElementById('files').innerHTML = showFolderFileList('C:');
        }
    </script>
    
    <input type='button' onclick='listFiles()' value='List Files' />
    <div id="files" />
    
    0 讨论(0)
提交回复
热议问题