2

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.

5
  • please provide the code you have tried Commented Jun 21, 2017 at 9:46
  • 1
    You should look at Electron, and then see this Commented Jun 21, 2017 at 9:47
  • @user93 To download the file ? Something close to this. Commented Jun 21, 2017 at 10:09
  • @NathanP. I will definitely try this afternoon. Commented Jun 21, 2017 at 10:09
  • Several browsers now support the File System Access API, which can be used to modify files on the local disk. Commented Feb 15, 2022 at 22:47

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I will definitely look into this this afternoon ! I'll keep you updated if it works for me. Thanks.
My Question: Then, how come app.diagrams.net can modify and save to local files if device option is chosen ?
0

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.

3 Comments

I don't know Node enough to see how it could help. Could you tell me very quick what could be done and how using Node ?
Node.js is just the framework, which let's you run JS on the Desktop/Server. Depending on your needs, you could use other frameworks like Electron (Desktop & Mac), Cordova & Ionic (Smartphone), which are also based on Node.js
If you need a GUI, i would recommend using Electron, it's simple to use and very well structured

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.