Giulio Muscarello
Giulio Muscarello

Reputation: 1342

How to write files on a server with JavaScript?

Environment: network, where each client is connected to a server. Internet access is disabled. The server cannot run server-side scripting languages or similar things, it can only be used to host files. [You know, the school server.]
Context: a chat which just shows a page (chat.html) which people edit in order to write a message. Simplified code:

<meta http-equiv="refresh" content="1">
<iframe src="chat.html">

Problem: editing may overwrite precedent edits.
Additional notices: The clients are (theorically) not allowed to run external programs.

The solution I thought about is the following: making a <form> which, once you send the message, edits chat.html, appends the message and closes the file. The problem is that I don't know how to open files. Also, I cannot use libraries like jQuery and so on, because the computer is "closed" (cannot access the Internet, nor download files from an USB drive).
What have I tried so far: Googled a while, but no solutions for opening files. Quite the same for SO: JS cannot access local files due to safety issues, but nothing about accessing files on servers.

Upvotes: 1

Views: 354

Answers (1)

GolezTrol
GolezTrol

Reputation: 116110

You can't. Client side Javascript cannot edit server files. Or any files for that matter. You will need service side scripting of any kind if you want to store files on the server.

The addition of libraries like JQuery wouldn't help either. They are just Javascript 'helpers' but cannot do anything that you cannot do using Javascript alone.

Upvotes: 5

Related Questions