1

i am trying to make a file in javascript, but it doesn't be saved in the root. when the file is made, the sentence i write has to be stored in the file. or loading a sentence from a textbox is also fine for me. can anyone give me help??

function createFile() {
var fso = new ActiveXObject('Scripting.FileSystemObject');
var fileObj = fso.CreateTextFile("G:\\soonrok.txt", true);
fileObj.WriteLine("Hello, I am Soonrok!!!");

}

<td>
    <input type="button" value="save" onClick="createFile()">

Albright
  • 109
  • 2
  • 12
  • 5
    ActiveX: How to make your site unavailable to most people in one easy step. – NullUserException Oct 11 '12 at 06:09
  • 1
    A previous question talks about how to do it in Chrome http://stackoverflow.com/questions/7160720/create-a-file-using-javascript-in-chrome-on-client-side but I am not sure about other browsers – AurA Oct 11 '12 at 06:11
  • 1
    @NullUserException - Coprporate LAN only implementation: how to make your site unavailable to all except those with permission to view (and a company mandated browser) Corporate IT 101 mate.. – enhzflep Oct 11 '12 at 06:18
  • @enhzflep - the real point is that ActiveX is an obsolete technology, and is known to be insecure, and only works in old browsers which are also known to be insecure. Corporates that are still using it deserve all the hacks they get. – Spudley Oct 11 '12 at 06:20
  • 1
    @Spudley - no doubt it's 'obsolete' (despite IE10 supporting it). Old bowsers only? bulsh1t. Deserve all the hacks they get? :Ooof: you trying to tell me that corps that have a lan that's not connected to a wan are susceptible? No more so than any other business is of being ripped-off by it's employees. Now then, the point of my remark was that it would be forgivable for thinking Null's comment was just as snarky and smart-assed as mine was.. It certainly added next-to-nothing, just as mine did! – enhzflep Oct 11 '12 at 06:49
  • Where do you want to create the file? On the client or on the server? Either way, good luck! – jahroy Oct 11 '12 at 09:10

1 Answers1

1

The best you're going to be able to do with JavaScript is create a cookie.

Or you could do something that only works for IE with ActiveX.

Or see the link from @AurA for Chrome Only tricks and/or ways to download files from a server.

jahroy
  • 22,322
  • 9
  • 59
  • 108