Jump to content
faure

WRITE a file upon hard disk of customer

Recommended Posts

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

 

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites
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!.

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×