Modify a local file with Javascript

ε祈祈猫儿з 提交于 2021-02-17 03:40:55

问题


I must make a local app with an interface. This app should load text files, modify them, and save them.

I made the interface with html/css/js, and the core of the app was made with js only.

Currently, I load the file with an input, but to save it, the browser makes me download it. I know this is a security measure.

This app is not going to be put online.

My question is : what can I do to replace directly the loaded file by the new one ?

  • Can I use my app (html/css/js) without a browser ?
  • Is there a browser that allows me to edit my local files directly ?
  • Is there any solution I can't think of ? Using another language to communicate with the js maybe ?

Thanks.


回答1:


If you don't need your app to be online, with Electron you can make an executable using your existing code (you will have change how you're going to save the file using Electron APIs). Being a program running on your system, you'll be able to save directly on the file system.




回答2:


JS in the browser is not able to edit local files, because of security.

If you want to, you can use Node.js, a Desktop/Server Framework, which uses JS.



来源:https://stackoverflow.com/questions/44672518/modify-a-local-file-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!