Click to See Complete Forum and Search --> : files support in javascript!


Konstanz
02-13-2003, 03:17 AM
Hello people. I need your advice. Image. I' d like to create a function on the web page in javascript that would open a file from exact path from client computer (for ex. c:/doc/temp.txt) and then show it on the web page as a webtext. That's my task.
I'd like to discus a ways of realisation. And to hear you ideas.
For getting full path to client file I use a form with a function:

<SCRIPT LANGUAGE="JavaScript"><!--
function validate() {
var filename = document.myform.mid.value;
}
//--></SCRIPT>

<FORM NAME="myform" onSubmit="return validate()">
<INPUT type="file" name="mid">
<INPUT TYPE="SUBMIT" NAME="mybutton">
</FORM>

The problem is that i don't know what to do further. I don't know the function that open a file from exact path. Please help me with it. And I'd like to hear your ideas about my task!

And the other question is. Can I do it writing java aplet?

Thanks a lot for help.

Konstanz

Charles
02-13-2003, 04:49 AM
Client side JavaScript has no file controls. That's why so many internet users are willing to put up with it.

AdamGundry
02-13-2003, 06:13 AM
If you want to simply open a local file, that's allowed by directing the browser to the appropriate address, for which you can use location.replace(). E.g:

location.replace('C:/doc/temp.txt');

So combined with your script, you get something like this:

<script type="JavaScript"><!--
function validate() {
var filename = document.myform.mid.value;
location.replace(filename);
}
//--></script>


While javascript cannot do anything to the filesystem, it can instruct the browser to display something.

Adam