0

When using the below code to try to open File Explorer to a folder path I get the errors SEC7134: Resource 'file://...' not allowed to load, and SCRIPT70: Permission denied.

However if I copy the exact path returned in the error and past it into the url it opens a new file explorer window without any issues. This was working at one time for me as expected, I'm wondering if there have been security changes or things that need to be updated on my side to open these files in File Explorer again.

Thanks,

function openFile(path) {
    // Internet Explorer 6-11
    var isIE = /*@cc_on!@*/false || !!document.documentMode;
    // Edge 20+
    var isEdge = !isIE && !!window.StyleMedia;

    if (isIE || isEdge) {
        window.location.href = path;
        return false;
    }
}
TylerH
  • 20,799
  • 66
  • 75
  • 101
pwned555
  • 19
  • 5

1 Answers1

0

Yes, we could use the browser as file explorer to retrieve the files in our local environment. But, reading local files from the browser (using JavaScript) is not allowed. This will prevent websites reading files and stealing your information.

If you want to display the local file using JavaScript, you could use the upload control select the local file, then, read the file and display it.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • I don't want to open a file, but a folder. Is this the same for opening folders? I've been able to use this code to open a folder location in the past. – pwned555 Jan 22 '19 at 20:29
  • Yes, I think it is same for the folders. you could also check [this thread](https://stackoverflow.com/questions/6506518/javascript-how-to-read-local-file). – Zhi Lv Jan 24 '19 at 01:30