Naman
Naman

Reputation: 1527

Creating File/Folder with pure JavaScript

I want to know more about FileSystem in Google Chrome, Mozilla or Opera . I have used FSO.js but it didnt help me to create, delete or list local files.

Is there any way of FileSystem with pure JavaScript?

Upvotes: 0

Views: 4140

Answers (2)

narainsagar
narainsagar

Reputation: 1129

As far as I know with Pure JavaScript It is not possible, Even with its libraries. & question is possible duplicate of this similar question and there is nice comment by @zerkms

If it was possible, what would prevent stackoverflow.com from writing an executable with virus to your autoload?

If you wish to write JavaScript programs that can create files on the users local file system you're going to need to write a client side app, such as a chrome app or write your program using Electron

However, if what you want is a cross browser solution to create files at specific locations on a user file system, it's just not really natively possible.

You may:

  • use LocalStorage if you just want to persist data to the client.

  • use NodeJS, Using this you will be able to require the File System core module and just create it using javascript as well. [P.S. Do some research on this]

Hope this helps.

Upvotes: 0

T.J. Crowder
T.J. Crowder

Reputation: 1075735

No, there is not. There was a brief attempt to create a sandboxed file area via the Filesystem API, but it was abandoned.

Right now, the only real file access you have in browser-hosted JavaScript code is via the File API, which is much more limited (though still really useful). It lets you read files the user explicitly gives you permission to read via an input type="file" or drag-and-drop event.

Upvotes: 2

Related Questions