Connecting Tech Pros Worldwide Forums | Help | Site Map

Reading / Writing a text file?

GlesgaMick
Guest
 
Posts: n/a
#1: Jul 23 '05
Ok, it must be one of the most fundamentally useful things in a programming
language, to be able to read and write files.

I want to know how i can do this in Javascript. I want to open a text
file, use it to fill some variables on a webpage. And have that webpage
save any changes.

Is there a single command like the C fopen("filename", "ra");?


David Dorward
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Reading / Writing a text file?


GlesgaMick wrote:
[color=blue]
> I want to know how i can do this in Javascript. I want to open a text
> file, use it to fill some variables on a webpage. And have that webpage
> save any changes.[/color]

http://jibbering.com/faq/#FAQ4_3

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Randy Webb
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Reading / Writing a text file?


GlesgaMick wrote:
[color=blue]
> Ok, it must be one of the most fundamentally useful things in a programming
> language, to be able to read and write files.[/color]

Depends on the programming language and its environment.
[color=blue]
> I want to know how i can do this in Javascript. I want to open a text
> file, use it to fill some variables on a webpage. And have that webpage
> save any changes.[/color]

If its running on your local computer, yes, under certain limitations.
If its a Windows based IE, you can use the FileSystemObject to read
files from the local drive and then save them, with security permission
given.

If you want to read/write files on a server, you can read them with an
HTTPRequestObject but JS has no ability to write files on a server, you
have to do that on the server.
[color=blue]
> Is there a single command like the C fopen("filename", "ra");?[/color]

Depends on where the files are. Whether they are on the users computer
or on the server. The FileSystemObject ActiveX in MSIE on a PC can do
that. Search MSDN.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Andrew Thompson
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Reading / Writing a text file?


On Sun, 24 Oct 2004 09:41:21 -0400, GlesgaMick wrote:

Given David and Randy have already contributed sensible answers..
[color=blue]
> Is there a single command like the C fopen("filename", "ra");?[/color]

You mean like..

<wild-ass psuedo-code>
IE.fopen("virus.exe", "e")?
</wild-ass psuedo-code>
GlesgaMick
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Reading / Writing a text file?


ok, thanks for the help guys, and no, i don't intend to create a virus,
its a uni project i'm working on, a rather annoying project, i won't bore
you with the specific details...

Closed Thread