...

View Full Version : Opening and editing files in Javascript



me'
12-31-2003, 02:15 PM
I've looked with Google, through Liorean's documentation threads and searched this forum, but I can't find how to open and edit files with Javascript! I thought it might be the classic var file = fopen('filename', 'mode'); but that doesn't seem to work. Any advice?

me'
12-31-2003, 04:02 PM
Never mind, I rephrased my search terms and it came up with a lot of different answers... bleh. This makes my life difficult.

Willy Duitt
12-31-2003, 05:09 PM
If it helps me'

Here is one method Vinny posted once:

<script type="text/javascript">
<!--//

//-----------------------------------------------------------------------
// author: Vincent Puglia
// site: http://members.aol.com/grassblad
//-----------------------------------------------------------------------

function loadFile(oSrc, oDest)
{
var fso, oFile, contents
var ForReading = 1
var txtFile = oSrc.value;
fso = new ActiveXObject("Scripting.FileSystemObject")
oFile = fso.OpenTextFile(txtFile, ForReading)
contents = oFile.ReadAll()

oDest.value = contents;
oFile.Close()
}

//-->
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<input type="button" value="Load It" onclick='loadFile(this.form.b, this.form.c)'>
<br>
<textarea name="c" cols="80" rows="25"></textarea>

</form>

.....Willy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum