Save data in a local file with HTML, Javascript? - javascript

I'd like to develop a simple offline html page to track my working hours. I'd need an offline file where I can put all my information and then retrieve them through Javascript. What do you suggest me? XML, Json, a DB? I need a "physical" local file because I would like to take my folder with all my html, css, and js files, put it in a pen drive and then open it in another computer. So something portable.

You can't do that offline; HTML/JavaScript doesn't have the ability to write to the filesystem. You can create cookies or use .localStorage in JavaScript, but that would only be local to your browser and won't be visible on another computer.
The closest thing you could possibly get is to write a page that stores data in localStorage and then run it from a portable version of your favorite browser that you also keep on your portable drive.

If you are not set on only using HTML, you might look into doing a C# windows form application.
You can find more on how to leverage that StreamWriter Class here:
https://msdn.microsoft.com/en-us/library/system.io.streamwriter(v=vs.110).aspx
However as for file type, a local JSON or .csv file should do the trick.

Related

Js - Create a file and save it to a specific folder in the project

I created an excel file via javascript, but when I need to save it the only option is to have the user open the download window and download the file. I, on the other hand, would like the file to simply be stored in a folder in my project, without the user having the option to download the file.
How can I do this? Thank you
You don't provide enough information but seems that you are doing it on the client side (i.e. a browser), which, in principle, does not have access to the file system on your computer/server.
You should try some Back-end approach, like, in your case with JavaScript: Node.js, or maybe anothers like Python or PHP.

Saving Form data to file

I want make a simple HTML application with a form. I want to be able to save the data to a file and also read it.
It will be an application that is just for offline use (me and 1 other person will use it). But since I won't be the only one using it I want to be able to share the data with the other person.
So using local storage is not an option. That data cannot be saved, and I don't accidently want to lose that data.
I also tried using blobs, but that only offers download option and it downloads to your download folder. I would like to save the file to the location of the HTML file.
Is that possible with plain HTML and JS? Or do I need to look into some other technologies?
Thanks in advance!
Browser javascript don't have access to the file system and so it won't allow to create file in the local directory. if you want to achieve such functionality you should try sending the file to backend like node js and write the file to the directory.

Possible download / upload manager embedded on html page with access to local filesystem

As the title indicates i want to have a certain application get access to the local file system. To describe why i will illustrate my situation:
I am a running a IIS WebApplication with the C# MVC 4 Framework as backend module. The site solely consists of HTML, CSS markup and some JS. The page will be loaded in IE11+ (Edge) only. For the standard procedure of displaying and accessing data from as well as sending data to the server this works quite fine.
On a certain page I want the user to be able to upload a file using a simple file dialog, like the one you can initiate with a simple <input type="file"> tag. I also want to offer the posibility to download files from the server but need to know where files has been saved / will be saved to.
As described on a lot of different websites, just like this one here, the HTML5 File API does a great job but will not be able to return the full qualified filename including the local path directions, same for JS accessing the file object.
As my research confirmed HTML5, JS and also SWF (Flash) will not report detailed information because they are all sandboxed applications or restricted by RFCs. I already unterstood and appreciate the effort to secure my trips to internet.
But in this case do need the paths where a file was upload from and the file has been downloaded to.
So my question is, what is the best way to expose the full path directions for a up- as well as downloaded file to report them back to the server?
Is it possible to embed a SWF object inside HTML which will run inside an Adobe AIR sandbox or is a signed JAVA Applet still the one and only solution to accomblish this security breaking task?
A solution i would also apreciate would be the possiblity to ask the user to get access the file system, like you grant access to the web push service to receive notifications.
Also if there is a possible solution which may suite my circumstances please let me know by adding some simeple examples / revealing some factful links, thanks in advance.

linking html web page to text editor to practice

I'm trying to link this page http://www.bauer.uh.edu/parks/f1471m.htm to my text editor ( text mate) with a mac.
I even copied the code and pasted it into an HTML file, and made a .js file (the one I'm trying to use to practice with) in the same folder and to use the local tag with no success.
I tried using src="http://www.bauer.uh.edu/parks/f1471m.htm" with no luck.
am I doing something wrong?
I'm making a few assumptions here...
From what you're describing, I think you're trying to directly edit the file. Unless you have write access on that server, what you're doing isn't going to work. Some web development software will allow you to do this, but most text editors don't.
Can you work on the file locally (on your computer's file system) and upload it to the server through FTP?
Many browsers give you the ability to save a page locally these days. That would set up the proper structure for you on your own machine. (FireFox can do this using Save Page)

Modifying XML((local file system)) file in browser and saving at same place

I need to modify an XML file from browser which is at local file system and save back at same place where it has been picked from browser.
I have searched a lot in google but didn't find any solution. Please help me on this.
You can read a file from the the local file system, but browsers (and JavaScript) will not ever allow you to save back to the file system.
You have a couple of options:
1 - use cloud storage and avoid the file system all together
2 - Create your own desktop app and wrap a web browser control. Then open/save the file in your own code, and pass it to the browser control.

Categories