View Full Version : read from a file?
alaios
09-24-2002, 08:47 PM
do u know if javascript can read or write to a file?
Mainly, you can't do that with just javascript. But you can use javascript to create an ActiveX Object and read and write files in the client's computer. Something like this:
var fileObj = new ActiveXObject("Scripting.FileSystemObject");
The only drawback is that the user must accept your ActiveX. Search the web for FileSystemObject for more info on how to use it.
beetle
09-24-2002, 08:57 PM
Well, yes and no. There are a few 'yes' cases.
Case #1
.js files can be read from and are (technically) external files (stored on the server)
Case #2
An aboslute URI can be a filename (file:///c:\Windows\etc....) but this path must be EXACT to the path on the client's machine, and the file linked to much be something the browser can handle (html, jpg, gif, etc) This is ok for just your computer, but no real practicality.
Case #3
I believe that Javascript can read/write from/to 1 or more XML technologies (but requires accompanying XML knowledge) Not 100% sure on this.
Case #4
There's probably something with ActiveX that you can use. Note: ActiveX will only work on Windows machines running IE
For every other case (that I can think of) the answer is 'no'.
alaios
09-24-2002, 09:13 PM
i want to write numbers in to one file and read again from the same file
beetle
09-24-2002, 09:17 PM
You're not helping us much here alaios. What sort of file do you want to write to? Or does it matter? Why do you want to do this? We can possible get around it using scripting variables, cookies, or search strings. More detials please.
alaios
09-25-2002, 09:06 PM
i want to store a number in to the server,
so every time one user is visiting the web page i want to read from the file and write again to it.
joh6nn
09-25-2002, 09:37 PM
can't be done with javascript
Roy Sinclair
09-25-2002, 10:06 PM
Originally posted by alaios
i want to store a number in to the server,
so every time one user is visiting the web page i want to read from the file and write again to it.
This is the kind of thing that require server side scripting ala CGI, Perl, Python, PHP, ASP etc. Of course your web host has to supply some form of server side scripting or it's not possible this way at all. As an alternative there are some hit counter sites you can use (but as always, there will be a price).
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.