If it’s in a browser that isn’t Chrome (and even then, only Chrome in specific configurations), you can’t: JS is sandboxed and cannot access the filesystem because that would be a huge security issue. The API for Chrome is here but is not usable out-of-the-box, a user has to install a Chrome extension to allow access to the local filesystem.
I am working on a project that almost looks like codepen.
It is very basic and will not work in the browser like codepen does but I am going to turn it into an apk for andriod phones.
Thanks for your reply that looks beautiful.
But I am finding it hard to get how the filesystem works because my knowledge level on coding is very basic though I have read on filesystem before.
What I am doing is write an html editor that have the ability to compile html,css and JavaScript onkeyup.
It is a simple project.
My intention is to make it an apk for andriod phones.
Which allows you to access the device filesystem. This is based on the deprecated JS FileSystem API. It works the same way – the plugin shows what the different storage location directory paths are, and this article may be helpful in showing you how the API works.
Yeah thanks, I noticed that. I add the document.getElementById(id) in the button onclick because that’s how I know I can get the value in the <textarea></textarea>.
I will edit the code and clear that part.
Any ideas on the file creating with the textarea value.
How are you packaging this code into an APK? This is very important information as it decides what system APIs you have access to that would allow you to save to storage.
OP is trying to build for Android @s0ukke05 , Node isn’t relevant here.
What I mean is that knowing what you are using to pack the JS into something that will work on Android is important. Accessing the filesystem is a system-level operation, the framework you use has to have a very specific API built in that allows it to bridge between the JS code and the system code, and that API is, unfortunately, going to be different for every framework. There isn’t a common way to do it. I’ve posted two links for two different APIs (Chrome browser and Cordova), neither of which will apply in this case and neither of which work (sorry!).