faure Posted January 5, 2018 Share Posted January 5, 2018 this function is not working function getdata() { var txtFile = "c:\test.txt"; var file = new File(txtFile); var str = "My string of text"; file.open("w"); // open file with write access file.writeln("First line of text"); file.writeln("Second line of text " + str); file.write(str); file.close(); alert("fin"); } have you a solution ? thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted January 5, 2018 Share Posted January 5, 2018 I assume you do have node.js installed or something similar? Link to comment Share on other sites More sharing options...
ScriptShow Posted January 14, 2018 Share Posted January 14, 2018 Hello, <html> <h2>Create Text file in JavaScript</h2> <script> function createFile(){ var object = new ActiveXObject("Scripting.FileSystemObject"); var file = object.CreateTextFile("C:\\Hello.txt", false); file.WriteLine('Hello World'); file.WriteLine('This Text is Write ...'); file.Close(); } </script> <input type="Button" value="Create File" onClick='createFile()'> </html> For IExplorer - Win. Only Test. Link to comment Share on other sites More sharing options...
Ingolme Posted January 14, 2018 Share Posted January 14, 2018 No, you cannot just put files on clients' computers, that would be such an easy way to install viruses onto the device of anybody visiting a website. Browsers do not, and never will, provide a method to write files on the computer. ActiveX hasn't been used in IE in over a decade because it was a big security vulnerability. Link to comment Share on other sites More sharing options...
ScriptShow Posted January 14, 2018 Share Posted January 14, 2018 17 hours ago, ScriptShow said: Hello, <html> <h2>Create Text file in JavaScript</h2> <script> function createFile(){ var object = new ActiveXObject("Scripting.FileSystemObject"); var file = object.CreateTextFile("C:\\Hello.txt", false); file.WriteLine('Hello World'); file.WriteLine('This Text is Write ...'); file.Close(); } </script> <input type="Button" value="Create File" onClick='createFile()'> </html> For IExplorer - Win. Only Test. For security reasons!. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now