chunks
January 30th, 2009, 11:26 PM
hi,
im using this code
<script>
function load()
{
var fso, f, r;
var ForReading = 1, ForWriting = 2;
var str='Scripting.FileSystemObject';
fso = new ActiveXObject(str);
var file = 'c:/testfile.txt';
f = fso.OpenTextFile(file, ForWriting, true);
var text ='Hello world!';
f.Write(text);
f.Close();
alert('done');
}
load();
</script>
to create a file on my Hard Drive by saving the page simply in Desktop and execute it by double clicking the page
this is a simple html page.
but i want to create this file on my localhost by putting this html file in my localhost and i want to execute this file like
http://localhost/dir/file.htm
but it does not create the file on localhost with this code
<script>
function load()
{
var fso, f, r;
var ForReading = 1, ForWriting = 2;
var str='Scripting.FileSystemObject';
fso = new ActiveXObject(str);
var file = 'http://localhost/dir/testfile.txt';
f = fso.OpenTextFile(file, ForWriting, true);
var text ='Hello world!';
f.Write(text);
f.Close();
alert('done');
}
load();
</script>
and shows an error like
bad file name or number
im using this code
<script>
function load()
{
var fso, f, r;
var ForReading = 1, ForWriting = 2;
var str='Scripting.FileSystemObject';
fso = new ActiveXObject(str);
var file = 'c:/testfile.txt';
f = fso.OpenTextFile(file, ForWriting, true);
var text ='Hello world!';
f.Write(text);
f.Close();
alert('done');
}
load();
</script>
to create a file on my Hard Drive by saving the page simply in Desktop and execute it by double clicking the page
this is a simple html page.
but i want to create this file on my localhost by putting this html file in my localhost and i want to execute this file like
http://localhost/dir/file.htm
but it does not create the file on localhost with this code
<script>
function load()
{
var fso, f, r;
var ForReading = 1, ForWriting = 2;
var str='Scripting.FileSystemObject';
fso = new ActiveXObject(str);
var file = 'http://localhost/dir/testfile.txt';
f = fso.OpenTextFile(file, ForWriting, true);
var text ='Hello world!';
f.Write(text);
f.Close();
alert('done');
}
load();
</script>
and shows an error like
bad file name or number