tags:

views:

909

answers:

5

is it possible to create a file on localhost with javascript?

+7  A: 

Not in a webpage. If you're using Windows Script Host then yes you can through ActiveX, but I presume you're not doing that. You can however, send data back to the webserver through AJAX and have it store it for you.

Ray Hidayat
+1  A: 

no, this would be a security issue.

You can create a file through a plugin, see https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO

Pierre
+2  A: 

You can create cookies to store data on the local machine, which pretty much is the only way to create files on the local machine.

I.devries
+3  A: 

While this is generally not possible, you could write an application which depends on a browser extension like Google Gears which allows more local storage than a cookie would allow.

Paul Dixon
A: 

Create File

function openFile() { var filePath = 'c:/filename.txt'; var fileSysObj = new ActiveXObject('Scripting.FileSystemObject'); fileSysObj.CreateTextFile(filePath); }

This will create a file called "filename.txt" on your c:\ drive.
You must accept the ActiveX control or disable prompting to create a file.

create file

arijit