Announcement

Announcement Module
Collapse
No announcement yet.

How to read and write a file using javascript?

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to read and write a file using javascript?

    How to read and write a file using javascript?
    Thumbtack Clone | Taskrabbit Clone

  • #2
    Files can be read and written by using java script functions fopen(),fread() and fwrite().
    The function fopen() takes two parameters 1. Path and 2. Mode (0 for reading and 3 for writing). The fopen() function returns -1, if the file is successfully opened.
    SEO Update | SEO Leap | SEO OFF Page Method

    Comment


    • #3
      you can use file handling. you can use fread() and fwrite() function.
      Telugu Matrimony | free matrimony registration

      Comment


      • #4
        For completeness, the OP does not state he is looking to do this in a browser (if he is, as has been stated, it is generally not possible)

        Comment


        • #5
          There are two ways to do it:
          1. Using JavaScript extensions (runs from JavaScript Editor), or
          2. Using a web page and ActiveX objects (Internet Explorer only)
          In JavaScript Extensions, you can use
          fh = fopen(getScriptPath(), 0); to open a file
          Using ActiveX objects, following should be included in your code to read a file:
          var fso = new ActiveXObject("Scripting.FileSystemObject");
          var s = fso.OpenTextFile("C:\\example.txt", 1, true);

          Comment

          Working...
          X