How to open a local disk file with JavaScript?

前端 未结 9 2006
[愿得一人]
[愿得一人] 2020-11-22 01:21

I tried to open file with

window.open(\"file:///D:/Hello.txt\");

The browser does not allow opening a local file this way, probably for sec

9条回答
  •  终归单人心
    2020-11-22 01:56

    The xmlhttp request method is not valid for the files on local disk because the browser security does not allow us to do so.But we can override the browser security by creating a shortcut->right click->properties In target "... browser location path.exe" append --allow-file-access-from-files.This is tested on chrome,however care should be taken that all browser windows should be closed and the code should be run from the browser opened via this shortcut.

提交回复
热议问题