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.
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.
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.
Related
I am developing in R/Shiny (which mainly makes use of JavaScript) to display the results of the web applications.
In one of our application, we must create an XML file and redirect the user to an URL that has this XML file path in its URL as an argument.
Something like :
http://path.to.my.service:1234/file=u:\my\shared\myxml.xml
At the moment, we create the file "myxml.xml" in a folder that is mounted both in the user and the server file system but I found this really unpractical and ugly. I'd rather create a file in the user local file system and have the link point to it.
I'd like something like :
http://path.to.my.service:1234/file=C:\Users\moi\AppData\Local\Mozilla\Firefox\Profiles\monprofil\myxml.xml
To this of course, I need :
to be able to create an XML file in an accessible dedicated directory (e.g. the browser cache dir)
to be able to have to path to it.
Do you see any way to achieve this kind of results?
Many thanks for your kind help.
Sylvain
Operating system : Windows 8.
Input-from : A text field from a html page .
Input-type: text.
Output : the file that was searched.
What I want : I want the user to enter some keywords and have JavaScript search the user's local files...
Is there any way? or A javascript Library?....
And how I can query the file system about the files using Javascript..in Windows..
EDIT::
Thanks everyone for the reply...
The way I get it is ,either I have to develop my own browser based in Java that has sufficient permissions.. or
I would have to implement a file crawler that indexes everything that sends that file to the a server , so that javascript can then access it through xmlhttp requests to the server ....
This was just a curiosity and I don't want to expose anyone's personal files on the Internet.
A fun project.. That all tinkered in my mind.
This is not possible from a web page because of the browser's security restrictions. You could access the local file system with Node.js or an Electron app, but I don't know if that would suit your use case
No. That's simply not possible and even if it is, it should not be used, as it would make one's local file system open to various threats because you are directly exposing your machine on the internet. That's sufficient enough reason for a webapp not to access one's local file system in any manner whatsoever.
P.S: If you really want it, There are a few third party libraries which use Sandboxed file systems. You can try that if you want.
I havent tried it personally, but found the below link via quick googling so i am not sure if its officially supported up until now.
https://www.html5rocks.com/en/tutorials/file/filesystem/
Use <input type="file">, which implements ability for user to select file from local filesystem.
Is there a way to replace a .js file in the website sources with a file on my workstation, or make a modification to a .js file and refresh the website to see the changes?
I am developing client-side JavaScript code against a SharePoint website on a server. I cannot create a local version of the website, so I need to modify the script, save the file to the server, refresh, etc. I do not have direct access to the server, and saving a file in a SP doc library or web part takes a lot of time between edits.
I can make small modifications using the dev tools while breaking on certain lines and applying snippets, but I am hoping for a better way.
Thanks!
If you have access the server that's hosting the file you should be able to replace or modify the JS file. Alternately you can use local hosting tools to test your file and then upload it to the server once you've confirmed it's working.
If you explain what you level of access to your host is we can offer better suggestions.
So I have this html page. Inside of it is a bit of javascript code that talks to a flash application.
During the flash application's lifecycle, it'll save a file to a place on the server using the javascript on the html page.
How can I use javascript to take the file I just saved and move it to a different location?
You cannot. Javascript works on a client and don't have an access to the server's filesystem.
You can only trigger a script on the server that does that.
As you said you have node js installed and running on the server,it is possible for you to move a file using the nodejs filesystem api: http://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback
For this to work you would need to monitor and detect when new files are saved in a certain folder, which should be possible using: http://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener
Happy coding!
In my web app I need to give the user the option to save a js variable as a file (when the user clicks download, the app offers him to save a file, preffereably as .js file).
Similarly as google docs offers you to save a file.
Is it possible for javascript to pass it's variable this way?
Check out Downloadify which allows exactly this.
Downloadify is a tiny JavaScript + Flash library that enables the generation and saving of files on the fly, in the browser, without server interaction.
it requires Flash installed in the user's browser to work, though.
I know of no other way of doing this without server interaction.
You might also want to check out OpenSave:
http://www.gieson.com/Library/projects/utilities/opensave/
... which looks much like Downloadify, but seems to have a few extra features (and not as complicated?).