Entry
how can i upload a local text file in a textarea control
Jun 24th, 2002 12:08
Jean-Bernard Valentaten, meem sheen,
Here's a basic approach:
1. Build a frameset, with one frame that has either 0px width or
height. The second frame displays your page
2. Find out the URL of the local file. If there is a webserver running
on the client-machine this should be no problem, but if there isn't,
you'll need to know the path to the file.
3. Set the source of the first (invisible) frame to the URL of the
file, which will load it.
4. Now you can access the content of the file via parent.frames
[0].document
Note: This will only work with files that are not associated with some
application or plugin and it won't work on all clients!!!
I'd say that this is quite a tough task. The only way that I can see to
make this work is to use JScript instead of JavaScript, since
Micro$ofts version of ECMAScript (the initial version of JavaScript)
implements an API that allows access to the whole system. This, of
course isn't very secure and makes the system vulnerable to remote
attacks and only works with IE5 or greater. Netscape, Opera and any
other browser doesn't support it for obvious reasons.
HTH,
Jean