1

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.

7
  • Using JavaScript call server side action. Like you can use servlet to post your file to server. Commented Nov 18, 2012 at 12:11
  • Javascript runs on client side. The server is a different computer that the client does not know anything about. So it obviously has no access to the server side filesystem. Commented Nov 18, 2012 at 12:42
  • @Esailija Not just server files. Browser scripts don't have file access at all. Commented Nov 18, 2012 at 14:38
  • @Esailija The client has read and write permissions on the server, anyway ("a page (...) which people edit in order to write a message"). Commented Nov 18, 2012 at 15:50
  • 1
    @GolezTrol yes they do with "html5" or flash Commented Nov 18, 2012 at 16:09

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.