Can JavaScript create a file ?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

Can JavaScript create a file ?

Post by Calimero »

The Idea:

I need JavaScript to create a blank file, and then populates it with some data on the clients computer - is this possible (automatically, or with prompting window of some kind - for user to allow this file creation),

and if there is can it of any extension.


Else ( Can, after php creates the file, javascript deploy that file ).


Any ideas and code snippets or reference referencing are welcome, thanks !
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Not on the users computer...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

simple answer: no to both. Javascript has zero access to the user's computer.
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

Ok, but my idea is based on the following:

Javascript can execute some file, can it pass some argument for that file to be executed (like copy / paste to clipboard),
so I run notepad, and insert data, and save the file - .... to desired location or to internet temporary files ...


The other way I planned is to prompt - or tell my users to create / save the file, anywhere on the hard-disk and when they log in again, my site (I don't know how :D should automatically call the contents of that file - for personalisation purpose.


Is this possible - in theory, I'm solving that problem now, the code is not neccecary - I have to do something on my own, right :D .

Tnks Ahd !
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why do you keep insisting on storing this data on their machine? We've told you many times now, use a database to store the information.

It's not possible for Javascript to access any file in the filesystem. Javascript can only access the content available through the page(s) it sits on or around.

Your server cannot pull a file from a remote location without that remote location (someone's computer) being either directly networked to the server or the remote location being a server in itself.
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

ok, ok,
just, I'm new to JavaScript,
I,m reading about it and trying to get the limits of the JavaScript and practical use of it.
Post Reply