问题
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