473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to read text file using JS without activex control?

I am trying to read text file , here is the code ,

I cant use activex control so plz give me some way....
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. function r()
  6. {
  7.     alert("Hkhi");
  8. var fh = fopen("G:\a.txt",0); // Open the file for writing
  9.  
  10. //var fh = fopen("C://Documents and Settings//Administrator//Desktop//log.txt",0);
  11. alert(fh);
  12. if(fh!=3) // If the file has been successfully opened
  13. {
  14.     alert("Hi");
  15.     var str = "Some text goes here...";
  16.     fread(fh, str); // Write the string to a file
  17.     fclose(fh); // Close the file 
  18. alert("Hi");
  19. }
  20.  
  21.  
  22. </script>
  23. </head>
  24. <body onload="r()">
  25. </body>
  26. </html>
Apr 4 '11 #1
8 12350
Dormilich
8,658 Expert Mod 8TB
you can’t do that. JavaScript is not allowed to access the client’s file system (ActiveX being the exception, obviously)

besides that, fopen(), fread() & fclose() are typical PHP functions (not sure about ActiveX, but it doesn’t seems like they belong there, too)
Apr 4 '11 #2
so you mean that its not possible to read file using js?

my problem is that I have to generate graph in html page using the parameter coming from one sensor , which are being stored in text file...

Is it possible to store this parameter somewhere and then accessed in js file? because I want that parameters in my file which is generating the graph..
Apr 4 '11 #3
Dormilich
8,658 Expert Mod 8TB
you can only access files from the server you serve your page from (cf. SOP (Same Origin Policy))
Apr 4 '11 #4
ok ,

So is it possible that I store parameters from local file using anyother language on webpage and the using JS access those parameters from that webpage?
Apr 4 '11 #5
Dormilich
8,658 Expert Mod 8TB
I don’t know any language that could access the local filesystem (besides JScript).
Apr 4 '11 #6
thank for your help and reply ,

Now I just need to access the file on server ,
Can you please give me way to read our values from the file lying on the same folder on server...
Apr 4 '11 #7
Dormilich
8,658 Expert Mod 8TB
that’s simple, just do an AJAX request of the file.
Apr 4 '11 #8
thanks but I dont know too much about how to use AJAX , can you please just show me demo code for that....
Apr 4 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: rishka | last post by:
Rishka Mar 17, 5:40 am show options Newsgroups: comp.databases.oracle.tools From: "Rishka" <ris...@webmail.co.za> - Find messages by this author Date: 17 Mar 2005 05:40:45 -0800 Local:...
2
by: Simon Verona | last post by:
Not sure if this is the best group... it may be better off in one of the ADO groups, but I'm sure somebody here knows the answer: I'm trying to load up a text file using ADO.net, as follows: ...
5
by: Mika M | last post by:
Hi! I'm trying to read text file like... "Field1";"Field2";"Field3";"Field4" "ABCD";"EFGH";"1234";"20051020" "AABB";"CCDD";"2468";"20051021" "CCDD";"XXYY";"4321";"20051022" ....using OLE...
1
by: JM | last post by:
Hi, I have been trying to read a file, using "StreamReader" to pass the info to an string that is: ....dim stream as new FileStream(file,...) dim sr as new StreamReader(stream) dim data as...
2
by: asenthil | last post by:
Hai, i'm a beginner to java... just now i had tried to read and write files using java... and then i had tried to connect a database using jdbc... now i want to export the data's from a...
1
by: sallu2000 | last post by:
hi to all, I am new to php,can u give any idea to read text file from folder based on datewise .for eg. in that folder there are three text file. one.txt 10/3/2007 two.txt 13/3/2007...
1
by: abtet | last post by:
Hello people, I am new to php and have question on how to read text file and convert it to XML with php. . Can it be done if the text file contains text, image and also tables? please help...
1
by: neveen | last post by:
i want to open and read text file using j2me that can run on mobile 6630 then i want to make button called read that when pressed the data inside text display
1
by: goelamit1982 | last post by:
How to Read multiple text file using XML and store into the database
7
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, I am using visual studio C# window and I have an xml file which I need to read that file using Object Oriented program. What codes I should use in my class to load and read that xml file....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.