View Full Version : txt file open
weknowtheworld
Apr 14th 2007, 11:52 pm
Hi,
Can anyone please tell me how Can I Open a Text File (*.txt) In a Textarea ?
Thanks :)
krakjoe
Apr 17th 2007, 7:34 am
u cant with javascript, you'll need to use a server side language to achieve that...
Subikar
Apr 17th 2007, 9:01 am
<script>
var fso, f1
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.CreateTextFile("C:\\WINDOWS\\Desktop\\file name.txt", true);
// Write a line.
f1.WriteBlankLines(1);
f1.Close();
function CreatAList(){
var MyWords = document.Picks.Selections.value
var fso, f1, ts, s, s1;
var ForReading = 1;
fso = new ActiveXObject("Scripting.FileSystemObject");
// Read the contents of the file.
ts = fso.OpenTextFile("C:\\WINDOWS\\Desktop\\file name.txt",
ForReading);
s = ts.ReadAll();
s1 = s+MyWords
ts.Close();
f1 = fso.CreateTextFile("C:\\WINDOWS\\Desktop\\file name.txt", true);
// Write a line.
f1.WriteLine(s1);
f1.Close();
}
</script>
In this way read the file and then display with document.getElementByid to textarea. Filename.txt content will be available in s1 string.
I think I am ble to help you out. Any help needed I am here to answer you. :)
krakjoe
Apr 17th 2007, 1:04 pm
nearly everyone will stop that activex running on thier computer, and those using firefox won't even get the option.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.