Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can javascript access a filesystem? [duplicate]

I was pretty sure the answer was NO, and hence google gears, adobe AIR, etc.

If I was right, then how does http://tiddlywiki.com work? It is persistent and written in javascript. It is also just a single HTML file that has no external (serverside) dependencies. WTF? Where/how does it store its state?

like image 363
Joe Avatar asked Jul 06 '09 14:07

Joe


People also ask

Does JavaScript have access to file system?

The main idea of the solution is: the JavaScript code cannot access the file by having its local URL. But it can use the file by having its DataURL: so if the user browses a file and opens it, JavaScript should get the "DataURL" directly from HTML instead of getting "URL".

Can JavaScript manipulate local files?

It can be concluded that although JavaScript cannot access local files directly due to privacy and security, the file can be selected through the “file input” element which can process the file. A “File Reader” can then be used to access the content of the selected files.

Can browser JavaScript access local files?

Web browsers (and JavaScript) can only access local files with user permission. To standardize the file access from the browser, the W3C published the HTML5 File API in 2014. It defines how to access and upload local files with file objects in web applications.

What is file system in Java?

A file system is the factory for several types of objects: The getPath method converts a system dependent path string, returning a Path object that may be used to locate and access a file. The getPathMatcher method is used to create a PathMatcher that performs match operations on paths.


1 Answers

Tiddlywiki has several methods of saving data, depending on which browser is used. As you could see in the source.

  • If ActiveX is enabled, it uses Scripting.FileSystemObject.
  • On Gecko-based browsers, it tries to use UniversalXPConnect.
  • If Java is enabled, it uses the TiddlySaver Java applet.
  • If Java LiveConnect is enabled, it tries to use Java's file classes.
like image 72
Zr40 Avatar answered Sep 22 '22 10:09

Zr40