View Full Version : Loading a textfile into a textarea on server

03-17-2005, 02:16 AM

I have abit of a problem, which is:

I'm using a textarea inbedded into an html page, which allows users to load in text files, mainly HTML into that textarea, which is then converted and the user can save the file to their desktop.

At the moment, I'm using the following code:

function readFile (fileName) {
if (document.layers && navigator.javaEnabled()) {
var bfr = new java.io.BufferedReader(new java.io.FileReader(fileName));
var line;
var content = '';
while ((line = bfr.readLine()) != null)
content += line + java.lang.System.getProperty('line.separator');
return content;
else if (document.all) {
var fso = new ActiveXObject('Scripting.FileSystemObject');
var fs = fso.OpenTextFile(fileName);
var result = fs.ReadAll();
return result;

This function uses an activeX control to load in the file.

I want to run the html page on a server, and still allow the user to be able to load a text file into the textarea.

However, I'm aware the above code won't work for this?

Can someone suggest a method by which I can? Unfortunatly the server I'm uploading to is not mine and I doubt the security settings can be changed because its on a very large network..

Thanks for any help in advance!