0

First I want to create a text file in local system and also add contents to the file, after that I want to open that file.

Can't create file using the code, also want code to open a file from local system. Can any one help me or provide with details that is it possible?

<body>

<input type="button" value="create" onclick="createFile()"/>    
  
 <script type="text/javascript"  language="javascript">

      function createFile()
                    {
                      try{
                            var fso,file;
                            fso=new ActiveXObject("Scripting.FileSystemObject");
                            file=fso.CreateTextFile("D:\\ppp.txt");
                            file.WriteLine("AAAAA");
                            file.close();
                        }
                           catch(err){
                               alert(err.message);
                           }                       
                    }

                  </script>

</body>

While running in IE got the error:

Automation server can't create object

running in Chrome got the error:

ActiveXObject is not defined

3
  • I think it is not possible. Commented Aug 2, 2013 at 10:59
  • possible duplicate of Is it possible to access local file via javascript? Commented Aug 2, 2013 at 11:00
  • Why your are not using Node.js library. It designed for that purpose only. Commented Aug 2, 2013 at 11:03

3 Answers 3

0

JavaScript does not have the rights to read/write the users filesystem. You can just use HTML5 localstorage to save data on the client.

Sign up to request clarification or add additional context in comments.

Comments

0

have a look at the post if you will read it with a cool mind you will get knowlegde

here

Comments

0

It is not possible in javascript , May be you can try Filesystem API which is currently supported in Chrome and Opera. You can read about it more here: http://www.html5rocks.com/en/tutorials/file/filesystem/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.