0

I am writing a front end program to load when my hard drive is plugged in. The file is called Boot.htm, so to get this name I use

var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);

Can I get the names of other files in the same place (root of hard drive), dynamically using just Javascript?

triplethreat77
  • 1,276
  • 8
  • 34
  • 69
  • 1
    No. Javascript running on a page in a browser does not have access to the local file system. – Felix Kling Sep 07 '14 at 18:03
  • I also suppose that you cannot but i found this post. Maybe it can help you http://stackoverflow.com/questions/4950567/reading-client-side-text-file-using-javascript – Ozan Deniz Sep 07 '14 at 18:04
  • 1
    That's not entirely true @FelixKling - a web page running from `file://` can read other files on the hard drive. I use one, it pulls in a local .txt file which jQuery then uses. Though I'm not sure that it would be able to read a directory index. – Popnoodles Sep 07 '14 at 18:23
  • @Popnoodles: yes, with the right settings you can make an Ajax request to get a local file. However, I rather meant something like node's fs module. – Felix Kling Sep 07 '14 at 20:19

0 Answers0