Archived     (close)   (home)
GalaSoft Laurent Bugnion This page is not maintained anymore, and has been archived. The information on this page must be taken with care, because it might not be valid anymore.
For more information, see this page or contact me
With the compliments of

Visit GalaSoft



See the demo


More information about WebLoadFile


Interested?

WebLoadFile is now
available for free!



Back home
WebLoadFile V01.03-04

Short story:

WebLoadFile reads files and passes the content to JavaScript.

Client-side JavaScript has some limitations.
For example, it is impossible for a webpage to access the server to load files other than .JS files.

Usually, the way to solve this problem involves some CGI working on the server, reading the files there and then building some HTML files "on the fly" with the file's content.
In some cases, however, this solution is not possible.

It is also impossible to read the list of all files present in a directory, or, for a script running locally, to read files on the user's PC.

WebLoadFile provides a solution in such cases.

Possible uses of WebLoadFile:
  • Building a Table of content for the website
  • Read ASCII or binary files and display or work with them
  • Use a browser as the base for an easy-to-build and flexible GUI instead of having to build a complete application
  • Check if a file exists
  • ...

WebLoadFile demo
Back to top

The server on which this page is placed is named "Demo".
The applet is placed in this folder. Thus, it is allowed to read it as well as the subfolders.

The applet automatically takes the color of the HTML background. This is why you cannot see it. It is sized to 1x1 pixel. This page contains 4 instances of the same applet, with different parameters, for demo purposes.
The first applet is here --> Your browser does not support Java... , another one is here --> Your browser does not support Java... , the third one is here --> Your browser does not support Java... , and the fourth one is here --> Your browser does not support Java...

Here is the structure of files and directories:

directory listing

Note that:
  • Demo.html is the file you're currently reading.
  • dirlist.gif is the image here above
  • WebLoadFile.demo.jar is a binary file containing the applet
  • WebLoadFile.js is an ASCII file containing the script
  • .bin files are binary files.
    They all contain 240 bytes, with values from 0 to 120 and down again to 0.
  • .txt are ASCII (text) files
  • .html files are normal HTML files.

And now to the demo itself:

Click on the button here under to browse the directories and to read all the files.


In this example, the applet's parameters are:
<PARAM NAME="FilesToLoad" VALUE="*.*">
<PARAM NAME="NavigateInSubdir" VALUE="1">

(the applet loads all files and is allowed to navigate in subdirectories).



Click on the button here under to browse the directories and to read only files with the extension ".txt".


In this example, the applet's parameters are:
<PARAM NAME="FilesToLoad" VALUE="*.txt">
<PARAM NAME="NavigateInSubdir" VALUE="1">

(the applet loads only TXT files and is allowed to navigate in subdirectories).




In this example, the applet's parameters are:
<PARAM NAME="FilesToLoad" VALUE="Test1.*">
<PARAM NAME="NavigateInSubdir" VALUE="0">

(the applet loads only files with the name Test1 and is NOT allowed to navigate in subdirectories).




In this example, the applet's parameters are:
<PARAM NAME="FilesToLoad" VALUE="demo2.html">
<PARAM NAME="NavigateInSubdir" VALUE="1">

(the applet loads only files with the name demo2.html and is allowed to navigate in subdirectories).
More details about WebLoadFile
Back to top

What is WebLoadFile?

WebLoadFile reads files from a webserver or from a local computer.

OK, but why is it special?

Client-side JavaScript has some limitations.
For example, it is impossible to access the server to load files other than .JS files.

Usually, the way to solve this problem involves some CGI working on the server, reading the files there and then building some HTML files "on the fly" with the file's content.

In some cases, however, this solution is not possible (CGI are not be allowed on some servers, for example). Plus, programming CGIs requires some knowledge in this field, something that not everyone can afford or is interested to learn.

So what do you propose? Is it secure?

WebLoadFile provides a solution. The Java applet is allowed to read files from the server it is on. There are, however, no security problems, thanx to the concept of "Sandbox", which is part of the language Java, and which allows the applet to only read files on its own server, and only in the directory in which it is placed (and of course subdirectories of this one).
First, the applet can load a listing of all files in the directories.
Then, the applet provides the content of the chosen file to JavaScript for display or to work with it.

Any other use? What about local files?

Another interesting case is when a programmer knows JavaScript, but doesn't know Java or C++ or another language allowing local file access. The programmer may want to load files to work with, however.
With WebLoadFile, the programmer can use a browser and JavaScript to make a GUI (Graphical user interface) very easily, and leave the complex part of loading the file to the applet.

Check if a file exists

WebLoadFile V1.3 now offers a method to check if a file exists or not.
The method "fileExists( String strFileName )" returns true if the file exists and can be opened, and false if not. It can be easily called from JavaScript to check the existence of a file on the server, or, if the applet runs locally, on the user's PC.

Is it easy to use?

A lot of people like to program JavaScript, because it doesn't need a special development environment, can be executed on browsers (present on every computer for free), and allows to build GUIs (Graphical user interface) at low development costs.
The applet does nothing but load the files. The rest is done in JavaScript and thus is very easy to adapt to every user's need!

What browsers does it work on?

WebLoadFile has been thoroughfully tested on Netscape 4.7, Netscape 7.0 and Microsoft Internet Explorer 5.0 on Windows NT, Windows 95, Windows 98, Windows 2000.
It will work on any version of Netscape 4.0 and above, and IE 4.0 and above.

It will work properly on any browser supporting Java, JavaScript and the interaction between them (named LiveConnect).
Note: IE for Macintosh is reported to have many problems with LiveConnect. It is possible that WebLoadFile doesn't work properly on IE for Macintosh.

Any known problems?

Some webservers disallow the loading of the directory listing.
In this case, loading a specific file will still be possible, but not the file list.

Back to top

WebLoadFile can be used to display a Table of content for a website, for example,
or to provide the user with a list of all files in a directory.
It can be used to display and work with the content
of ASCII (text) files or binary files.

Interested?