PDA

View Full Version : A serious suprise ! (to me at least)



pcbrainbuster
03-16-2007, 11:42 PM
Hello :),

I was just searching through the web today and found how you can opne and read files (but have not tried to find write and erase...yet) - here is the script -

<html>
<body>
<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>
</body>
</html>

Can anyone give me a tutorial on this or a site ?

djr33
03-16-2007, 11:54 PM
ActiveX is IE only, so that's no fun.

I don't know much more about this, though, sorry.

pcbrainbuster
03-16-2007, 11:58 PM
Thanks though, i forgot it was only ie :(...

But oh well...

boxxertrumps
03-17-2007, 12:10 AM
You cant write or erase files client side.
And this looks like ajax...

thetestingsite
03-17-2007, 12:13 AM
You cant write or erase files client side.


Correct you are. Unless you use some server side language with an AJAX invocation.



And this looks like ajax...

Nope, just ActiveX control for IE.

djr33
03-17-2007, 12:15 AM
Note "ActiveXObject" in the code ;)

mburt
03-17-2007, 01:44 AM
Yes, it would be much more effecient to do so server-side.

tech_support
03-17-2007, 03:24 AM
But you could still read files with ajax.

tech_support
03-17-2007, 03:36 AM
Server-side is not neccessary. You could just make a request direct to the text file.

djr33
03-17-2007, 04:00 AM
Those last two posts confuse me.

AJAX would require server side code in the page that is retrieved via ajax.

And, you can't read a text file on the user's computer without ActiveX, or Java. (Or flash, in some cases, and of course cookies, but those are limited).

tech_support
03-17-2007, 04:01 AM
I'm talking about reading the files on the server, not on the computer.

jscheuer1
03-17-2007, 07:38 AM
I'm talking about reading the files on the server, not on the computer.

But, pcbuster was talking about files on the computer. At least that is what that code does. I ran across it or something similar awhile back and it works but, I don't see much good that can come of it.

pcbrainbuster
03-19-2007, 06:00 PM
Sorry for posting about a day late, my internt stopped working and now it is obviously fixed...

Well alot of good can come from it really, like if a writing function is available you can write to a file for example the value of a text box and then using ifs and elses you can read the value(s) to "edit" the page...

Butterfly
03-20-2007, 06:46 PM
Look here! and this is compatible with IE and Firefox: http://www.galasoft-lb.ch/myjavascript/CExplorer/index.html. I used it for a JavaScript game in order to save and load characters and it worked really well.

Bob90
03-20-2007, 07:09 PM
ActiveX CAN change files on the Clients computer.
Come on, surely you know why you get all the activex alerts for! - Beacuse there used to be a virus that deleted your hardrive contents.

tech_support
03-20-2007, 09:32 PM
ONLY on INTERNET EXPLORER and IT WILL present you with a warning

tech_support
03-21-2007, 05:15 AM
Look here! and this is compatible with IE and Firefox: http://www.galasoft-lb.ch/myjavascript/CExplorer/index.html. I used it for a JavaScript game in order to save and load characters and it worked really well.
1. It will present you with a warning
2. It doesn't work on the WWW. (http://www.example.com/)

This is a useless arguement, you CANNOT change files on a user's computer, or else the internet will be more dangerous than it is already.