Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read File in JAvascript

Status
Not open for further replies.

mthirumalai

IS-IT--Management
Dec 19, 2002
3
US
How can I read the content of a file (in server) and display the content in a table widnow ?

thanks

 
hie

read file..

on server..

with client side langauge?

well, what about making contents of this file to be some sort of variable/array, and then - output 'em (document.write/innerHTML/etc) in youyr table?
 
hi

thx for your help.

How to make it inti a variable/array within the JS scope ? Can you help ?

thx again
 
i can try 2 help.. :)

if that file contains text, make it look like this:

file sometext.txt

````````````start
myText = "text text text text text text text text \n"+
"text text text text text text text text \n"+
"text text text text text text text text \n"
`````````````end of file

or whatever..


and then in your html file

...
<script src=sometext.txt></script>
<script>
document.write(myText)
</script>
...


understandable?
 
thx vituz,

this method works fine.

But the file contains dynamic content. The content will change once every week. To maintain it with the myText=&quot;contet....&quot; may not be efficient.

Is there any other way ? I saw in a netscape site that you can use File Objects in Javascript. This Fiel object has read, open, close methods. I am unable to make it work. I get a file error when I try to open the file.

Any other means/solutions - most welcome.

thanks again for your effort

 
hi again
yup, js has FileSystemObject, but as far as i see, it would try to open file on the local machine, wich is prohibited by security reasons (at least user would be warned that page is containing some activeX code wich might be dangerous for him/her..)

javascript is a CLIENT side language, and you're trying to open file on the server.. you'll have to use some server side code (don't know, asp/php/perl/cold fusion/whatever)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top