JUpload Classic

User Manual

Haller Systemservice


JUpload
1. Installation
1. System Requirements
2. Plug and Play - The fast way
3. Client-Side: Displaying the Applet
4. Server-Side: Save uploaded files
2. How does JUpload work?
1. Run JUpload
2. Overview
2.1. Look And Feel (L&F): The overall appereance
2.2. The FileChooser-Dialog
2.3. Drag and Drop (DnD) + Copy and Paste
2.4. The Toolbar
2.5. UploadViews
2.6. Uploading and Upload-Progress
2.7. Server Response
2.8. Capturing screenshots
2.9. Proxy Support
3. Special Features
3.1. The Upload-Structure: Files and Folders
3.2. Thumbnails: Create and upload image-thumbnails automatically
3.3. Custom User-Input
3.4. Validity-Check: Do not make unnecessary uploads
3.5. Multi-threading: Make everything work at once
3. Advanced Settings
1. Localization
2. Debugging
3. Verifying Data Integrity
4. Resigning the jar File
5. User-Authentication
6. Secure servers (SSL)
7. Customizing with Parameters
4. File-Reception - Scripts on your webserver
1. Meta-Information from JUpload
2. Using the POST-Method
2.1. Configuring PHP
3. Using the PUT-Method
4. Configuring and customizing the upload-scripts
4.1. Set the variables
4.2. Embedd the receiver in your own script
5. Javascript and how to use it to enhance the JUpload-Experience
1. What is the Javascript API?
2. General and privileged Functions
3. Listeners
4. Javascript - Examples
6. Updating from JUpload 0.89 and before
1. Parameters
2. Javascript
3. JUploadForm
4. File-reception on the webserver
5. Other
7. Solving common problems
1. Applet not loading or not uploading
1.1. Loading Java Applet failed...
1.2. SecurityException: Access Denied
1.3. Invalid Settings: Could not parse parameter
2. Look&Feel (L&F) does not change or show up
3. Cannot redirect
4. Applet changes are not displayed
8. Builtin Plugins
1. FileChooser Plugin
1.1. Configuration
1.2. Embedding the FileChooserPlugin
1.3. Javascript-Interaction
2. FolderChooser Plugin
2.1. Configuration
2.2. Embedding the FolderChooser Plugin
2.3. Javascript-Interaction
3. FileTypeChooser Plugin
3.1. Configuration
3.2. Embedding the FileTypeChooser Plugin
4. DragNDrop Plugin
4.1. Configuration
4.2. Embedding the DnDPlugin
5. ImagePreview Plugin
5.1. Configuration
5.2. Embedding the ImagePreview
5.3. Javascript interaction
6. ProgressMeter Plugin
6.1. Configuration
6.2. Embedding the ProgressMeterPlugin
A. Appendix
1. License Agreement
Bibliography
B. Reference
1. An overview over all configurable JUpload-Parameters
2. JUpload's Javascript API-Reference
2.1. Types used in the Javascript-Api
2.2. Javascript-Listeners

JUpload

Welcome to JUpload: The most comfortable and most powerful browser-embedded upload-extension

JUpload is a which enables any common browser to upload local files to a webserver using the standard HTTP-protocol supported by a simple though powerful and dynamic User-Interface with a lot of options for the webdesigner to customize.

Main Screen of JUpload

JUpload's strong points:

Security

Secure-HTTP (through SSL), authentication-support

Intranet

Complete Proxy server support

Userfriendly

Very easy to use; Image-Previewing, Drag-And-Drop, Progress-Information etc

Structured

Uploads files, folders and subfolders in a self-arrangable Upload-Structure

Customizable

Activate and configure all the components you like and deactivate those you do not like

Customize the user-interface: Change labels, colors, make your own skin or download one of many choosable themes

Use the power of javascript to re-design parts of the GUI, do a complete make-over or write powerful addons

Write your own plugin or use one of those that are already there

Progress

Displays detailed progress-information

File types

Supports more than 90 mime types, can upload all files

Thumbnails

Automatically creates and uploads thumbnail

PHP,ASP,...

Supports any server side scripting languages

Speed

Very fast

Ease of use

The user interface is intuitive, easy to understand and though powerful

Licensing

Free for private and cheap for commercial customers

Developers

API documentation & source-code available; Extendable through easily developed Plugins

Powerful

Extended Javascript- and Plugin- Support

Server

Server-independent

Safety

Resume uploads using the HTTP-PUT-Method

No limit

There are no artificial limits in JUpload

Mobility

It's platform independent; runs on Windows, Linux and Mac

For technical support, please go to the official Jupload product support page at jupload.biz

Chapter 1. Installation

The fast guide to get JUpload up and running

1. System Requirements

Client

  • Java Plug-In, Version 1.4 or greater - Microsoft Java is deprecated and thus not supported.

  • A compatible Browser (e.g. Microsoft Internet Explorer, Mozilla Firefox, Opera)

  • Internet Connection with open outgoing HTTP ports in firewall

Server

  • A webserver that is able to deliver binary data, so the Applet can be downloaded by the users. (eg. Apache at http://httpd.apache.org/ or alternatively you can install XAMPP which includes Apache, PHP and many other useful extensions, ready to run. You can find it at http://www.apachefriends.org/en/xampp.html)

  • Support for PHP, ASP, Perl or any other script-language that supports handling of HTTP-POST- or HTTP-PUT-Requests (already included in XAMPP)

2. Plug and Play - The fast way

Uncompress the downloaded archive jupload.zip (name may vary) into a directory beneath the DOCUMENT_ROOT of your webserver.

Make sure that your current server-settings are according to JUpload's current configuration.

Now simply use your browser to navigate to the correct location of the index.html on your webserver and JUpload should load up and be ready to use.

When using Apache, you can see all uploaded files by simply navigating to the "JUpload/uploaded/"-directory. The delivered .htaccess-file should enable auto-indexing of all files and sub-directories within this directory.

Note

Your webserver might have prohibited use of automatic indexing in general or only for this folder or for its subfolders. In that case please consider your webserver's manual.

Warning

Everyone accessing this page, can now upload files. To prohibit that, you can enable User-Authentication.

Tip

To do further customization, refer to the Advanced-Section.

3. Client-Side: Displaying the Applet

The files for JUpload and its embedding HTML-Page

  • /index.html

    An HTML-Page embedding JUpload:

    The core for embedding JUpload is t Applet-tag which looks something like this by default:

    <applet
    		title="JUpload"
    		name="JUpload"
    		code="com.smartwerkz.jupload.classic.JUpload"
    		codebase="."
    		archive="
    				dist/jupload.jar,
    				dist/commons-codec-1.3.jar,
    				dist/commons-httpclient-3.0-rc4.jar,
    				dist/commons-logging.jar"
    		width="640"
    		height="480"
    		mayscript="mayscript"
    		alt="JUpload by www.jupload.biz">
    
    	<param name="Config" value="cfg/jupload.default.properties">
    
    	Your browser does not support applets or you disabled applets in your browser-options.
    	To use this Applet, please install the newest version of Sun's Java Runtime Environment (JRE).
    	You can get it from <a href="http://www.java.com/">java.com</a>
    
    </applet>

    The Applet-settings in Detail:

    applet

    The Applet tag tells the browser that a Java-Applet should be embedded here. The attributes have all required information for Java to find and run the specified Applet from the given archive.

    name

    The name of the Applet, that Javascript is using to access JUpload with.

    code

    The code tag specifies the location and name of the main class within the delivered archives.

    codebase

    This is the location where the jars, specified in archive are to be found. Also all relative URLs used within JUpload are relative to the Applet's codebase.

    archive

    The archives are relative to the codebase or absolute and contain the Applet and further classes that are required by JUpload.

    All archives that are doing certain GUI-interactions, using network-connections or are accessing the local file-system need to be signed. See information on signing.

    The archives delivered with the download package are already signed as needed.

    width, height

    These two attributes specify the dimension (size) of the Applet. You can specify them in pixels or -by adding a "%"- in percent. Eg. width=800 or height=50%.

    mayscript

    This toggles wether or not Javascript is allowed to call methods of the JUpload-Applet (see the chapter on Javascript-Support).

    param

    The <param> tags can be used to configure the Applet. All supported parameters are described in the configuration-chapter. Names and values must be quoted. Also note that the names and values are case-sensitive.

    Since JUpload 0.90 this is not the preferred way to configure the applet anymore. It is rather recommended to simply write the configuration to a config file which will then be the only specified <param>-tag:

    <param name="Config" value="location/to/the/config.properties">

    This will make JUpload connect to the given URL (absolute or relative to the Applet's codebase) and download the config file for further use.

    Example 1.1. Config-File Example

    The config file replaces the <param>-tags with simple key=value - pairs, seperated by lines. If this parameter is specified, all other <param>-tags are ignored.

    The old-fashioned configuration:

    <param name="Files.Convert.Format" value="jpg">
    <param name="Files.Convert.InterpolationAlgo" value="bilinear">

    Is now replaced by a config-file with the following content:

    Files.Convert.Format=jpg
    Files.Convert.InterpolationAlgo=true

    Note

    The config file entries are not quoted.

    Don't forget to add the config-file's location through the Config-Parameter as shown above.


    If you do not want to use a config file, remove the Config-<param>-tag and add all the file's settings in the old-fashioned style as <param>-tags into the Applet-tag.

    [1]

  • /index-js-test.html

    Embedds JUpload and demonstrates the usage of the Javascript-API.

  • /cfg/jupload.default.properties

    The Config-File for JUpload is a simple text file and can be opened with any text-editor (such as Notepad).

    It consists of simple key=value pairs and replaces the definition of JUpload's parameters through Applet's <param>-tags (see above for more information).

    Upload.URL.Action=http://some/very/very/very/very/long/long/long/long/long/long/long/long/long/long/long/long/long/long/url

    You can add comments, by preceeding the line with a "#":

    # This is a comment and will not be evaluated

    You can distribute a parameter-definition over several lines by placing a "\" at the very end of a line:

    Upload.URL.Action=http://some/very/very/very/very/long/long/long/long/long\
    /long/long/long/long/long/long/long/long/long/url

    For more flexibility or user-specific config-files, you can simply replace the URL with the location of a script-file (PHP, ASP, Perl etc) which then replaces the parameters based on information read from a database or similar.

  • /dist/jupload.jar

    The JUpload-Applet itself

  • /dist/*.jar

    Further libraries, needed by JUpload

  • /dist/skinlf/*.*

    The skinlf with a few skins. See the Look&Feel - Section for further details.

  • /uploaded/files/ and /uploaded/thumbnails/

    The folders that the delivered scripts are configured to upload files and thumbnails correspondingly to by default.

  • /uploaded/.htaccess

    An .htaccess-file for apache to automatically index all uploaded files when accessing this directory

4. Server-Side: Save uploaded files

The script files, responsible for reception of files

  • /scripts/php/jupload-post.php

    A php-script for file-reception using HTTP-POST

  • /scripts/php/jupload-put.php

    A php-script for file-reception using HTTP-PUT

  • /scripts/php/inc/jupload.inc.php

    File that is included by both PHP-Scripts mentioned above. Provides functions and functionality which is needed by both script files.

  • /scripts/php/inc/jupload.cfg.php

    Configuration for file-reception

  • /scripts/php/listener/JUBaseListener.class.php

    Abstract Listener for Upload-Events. Implement this for custom file-processing and set the config correspondingly.

  • /scripts/php/listener/JUDefaultListener.class.php

    Default listener for Uploads - simple Listener-Implementation to provide basic information about the received files

Please see the chapter on File-Reception for further information.



[1] If your configuration includes characters that are not part of the Latin1-character-set (certain special characters or characters of any non-roman language), please consider the following, as stated in Java's documentation:

The stream is assumed to be using the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, can be represented in keys and elements using escape sequences similar to those used for character and string literals.

Unicode-escaping is described in chapter 3.3 of the Java Language Specification.

Chapter 2. How does JUpload work?

A brief overview over all of JUpload's features and how they work

1. Run JUpload

Use the webbrowser to go to the address of the JUpload-embedding HTML-Page. JUpload will automatically load.

While Java is loading the archive, a progressbar is shown.

When the Applet is fully loaded, the Java Plug-In will check its certificate. It will show a dialog with information about the certificate which was used to sign the Applets archive. Please check the certificate for correctness and accept with Yes or with Always.

Figure 2.1. Java Security Dialog on Windows

Java Security Dialog on Windows
Java's Security Dialog on Windows

Figure 2.2. Java Security Dialog on MacOS X

Java Security Dialog on MacOS X
Java's Security Dialog on Apple MacOS X

2. Overview

After JUpload has loaded and the certificate has been accepted, the main window will appear. After adding some files, it should look similar to this:

Main Screen of JUpload

2.1. Look And Feel (L&F): The overall appereance

The LookAndFeel (L&F) defines how the Applet should look like. It defaults to the Windows-LookAndFeel under Windows and the "Metal"-LookAndFeel under any other OS.

JUpload has the amazing feature to change its L&F in 3 simple steps:

  1. Choose one L&F from many places:

    • Any of Java's defaults: WindowsLookAndFeel (only available on Windows) (short: windows), BasicLookAndFeel (short: basic) or MetalLookAndFeel (short: metal)

    • Use JUpload's integrated built-in support for the SkinLookAndFeel by l2fproductions (short: skinlf):

      1. Choose a skin, eg from: http://javootoo.l2fprod.com/plaf/skinlf/index.php or use JGoodies.

      2. Add the skin's jar-file(s) to the Applet-tag's archives in the embedding HTML-Page.

      3. Specify the fully-qualified classname through Gui.LF.SkinPackUrl.

    • A major collection of further L&Fs can be found at http://javootoo.l2fprod.com/.

    • Create your own LookAndFeel or (way easier) Skin or have a Java-Developer do it for you

  2. Add the L&F's jar-file(s) to the embedding HTML-Page (Not needed if using any of Java's default L&Fs)

    Add the location of the jar-file(s) (absolute or relative to the Applet's codebase or (if codebase left empty) the embedding html-file) to the Applet's archive-tag, seperated by comma.

  3. Set Gui.LF.Classname to specify the fully qualified classname of the L&F.

    You can use the shortcuts metal, windows, basic and skinlf for the corresponding L&Fs mentioned above.

Done. You can now see JUpload in a completely new look.

2.2. The FileChooser-Dialog

The FileChooser-Dialog opens, when clicking on the Add Files - Button in the toolbar.

Within the FileChooser you can see the preview of selected image-files on the right side which can be deactivated.

You can change the FileFilters which are used to hide and prohibit adding of files which should not be uploaded at all. The FileFilters appear at the very bottom ("Files of Type"). In JUpload, there are predefined FileFilters and -if that is not enough- you can create and add your own FileFilters using Gui.FileChooser.Filter.Multi.

Select one or multiple files with a single left click and the help of the CTRL- and SHIFT-key. If you want to select all files, press CTRL + 'A'. This works in the filechooser, as well as in the UploadViews.

You can deactivate this Dialog by removing the corresponding button from the toolbar and add the JUpload's own FileChooser-Plugin and/or FolderChooser-Plugin to the page instead.

The file chooser can also display previews of images

2.3. Drag and Drop (DnD) + Copy and Paste

You can use Drag&Drop (short: DnD) to drag files from the explorer or any other external file-manager directly into JUpload.

Select the files or directories to be uploaded and do not release the mouse button. Now, move your mouse over to the running JUpload Applet. Move the mouse into the folder of your choice within the TreeView and release the mouse button. The files will now be added to the corresponding folder.

Also you can drag and drop folders and files within JUpload to any other folder to re-arrange the Upload-Structure.

Alternatively you can paste files, folders or images that you copied in another application directly into JUpload.

Dragging files out from JUpload is not supported.

2.4. The Toolbar

The toolbar at the very top top contains several control-buttons and can be customized through the Gui.Toolbar.Buttons-Parameter.

The Upload Files - Button becomes the Stop Upload - Button during the upload-process.

The Toolbar

2.5. UploadViews

The UploadViews display all files and folders which will be uploaded in a hierarchical structure when the user presses the Upload Files - Button.

By default there is the TreeView which displays the folders on the left side and the three other views on the right: The ListView with optional thumbnail-display, the DetailedView displaying additional information about the file or image and the ThumbnailView (or ImageView) which displays thumbnails of all images.

If you rest the mouse-cursor over a filename for a few seconds, you will see a tooltip containing the path of that file.

To remove files, select them using the mouse (single click for single files; hold SHIFT or CTRL to select multiple files) and either press "DEL" or click the Remove-button. No files will be erased from the hard disk.

You can change the order of or remove views through the parameter Gui.Views.Display. Further changes to the views can be done, using other Gui.*-Parameters.

The ListView

The DetailView

The ThumbView (ImageView)

2.6. Uploading and Upload-Progress

After adding all files, you can start the upload process by pressing the Upload-button. Press it again to cancel the upload.

While uploading, you will see a status display on the bottom of the Applet which can be expanded or collapsed by simply clicking on its title.

When using HTTP-PUT, you can resume the upload. Simply add the same files again and click the Upload Files - Button and only the rest of the file will be uploaded.

The upper progress bar will show the progress of the current file, the lower one shows the total progress.

An upload is currently being processed

2.7. Server Response

After the server received all files, it can send HTML-formatted text which will then be displayed in the ResponsePanel ("Server Response") at the bottom.

It is activated and collapsed by default. To disable it, set the Gui.ServerResponse.Enable-Parameter to false.

You can expand it by clicking on its title but it will be empty until it receives the first response from the server.

When information is received, it automatically expands. This behavior can be changed through the Gui.ServerResponse.AutoShow - Parameter.

Its height can be changed through the Gui.ServerResponse.Height - Parameter.

The Response Panel shows the server's reply

2.8. Capturing screenshots

JUpload is able to capture screenshots of the complete desktop or only JUpload respectively. If multiple screens are installed in the machine (dual-head), the user is asked for the screen to be captured.

The delay time before the capture can also be changed.

You can add or remove the corresponding buttons in the contextmenus through the Gui.ContextMenu.*-Parameters.

2.9. Proxy Support

JUpload fully supports proxies, using Basic-, Digest- or NTLM-Authentication. You can set up proxy-support under Tools -> Settings -> Proxy Login.

The windows-domain only needs to be entered when using NTLM-Authentication, and will be ignored in any other case.

Corporate users might need to set up an Intranet Proxy

3. Special Features

3.1. The Upload-Structure: Files and Folders

JUpload allows the user to upload files in a hierarchical structure which can easily be re-arranged, using DragAndDrop.

The structure allows files to be in folders and subfolders: All files and folders are within the root-folder. The root-folder is the "/" - Folder to be seen at the top of the UploadTree. This folder -as well as any sub-folder- can hold further sub-folders and files. The files will be shown in the ListView, DetailedView or the ThumbnailView on the right while all folders are shown in the TreeView on the left.

You can deactivate this feature and prohibit the use of folders in three simple steps:

  1. Deactivate Folders using the Files.Filter.Folders - Parameter

  2. Deactivate the UploadTree by removing tree from the Gui.Views.Display because it would become unnecessary

  3. Deactivate the AddFolder - Button from the Gui.ContextMenu.* - Parameters

Now the user cannot create subfolders anymore and will not see the UploadTree-View. To re-enable the feature, simply reverse the three steps.

The server can use Meta-Information sent by JUpload to determine in which folder a file is.

3.2. Thumbnails: Create and upload image-thumbnails automatically

JUpload can automatically create and upload thumbnails of image-files.

The thumbnails will be uploaded right after all files have been uploaded.

Use the Upload.Thumbnails.* - Parameters to customize this behavior.

Example 2.1. Thumbnail-Configuration Example

# Activate Thumbnail support
Upload.Thumbnails.Enable=true

# The location of the thumbnail-receiving script
Upload.Thumbnails.TargetURL=http://www.mydomain.com/thumbnails/jupload-post.php

# The maximum size of the thumbnails (resizes in proportion if either width or height exceeds their limit)
Upload.Thumbnails.Size=80x80


Note

The receiving script can determine wether the received file is a thumbnail or a file. See Meta-Information for details.

3.3. Custom User-Input

JUpload also can submit custom user input (eg from textareas, checkboxes etc) from the embedding page.

The feature is disabled by default and can be activated by setting the Upload.Formname. All elements of the specified form will then be sent via GET with each Upload-Request.

In PHP for example, all values (text, checkbox-/radio- selections, options, lists, buttons) of this form are stored in the superglobal: $_GET

Note

You do not need to add this form for hidden-values. You can add constant GET-values (not changable by the user) through the Upload.Http.Query-Parameter.

3.4. Validity-Check: Do not make unnecessary uploads

JUpload always checks first if supplied authentication, proxy-settings and the supplied user-input is accepted by the server with a HTTP-HEAD-Request. With this first request no files are uploaded.

Depending on the statuscode of the response-header of the server, JUpload can then determine wether or not to actually upload the files.

For that you need to set the Upload.Http.ExpectedHeaders-Parameter (or the status-code will be ignored): If set (and only if set) JUpload will not attempt the upload in case that the server responded to the HEAD-Request with anything but one of the expected headers.

The status-header must be the first header and it must be valid (or else it might be replaced by the webserver).

If JUpload idenitifies a header not to be valid, it cancels the download and shows the status-info as error-message.

See the configuration-example using PHP for details.

3.5. Multi-threading: Make everything work at once

JUpload is multi-threaded which simply means that it can perform several operations at once.

Save multi-threading allows the user to still edit the upload-tree while JUpload is uploading without messing up the upload or the structure of the uploaded files. This is because the files that are being uploaded will not be affected by any changes within JUpload.

This feature can be deactivated through the Gui.DeactivateOnUpload-Parameter

Note

It is completely save to let the user still add, remove or rename files or interact in any other way while uploading.

Chapter 3. Advanced Settings

The main features are not enough? Have a look on how to customize JUpload with over one hundred different settings and options

1. Localization

Do you have an international user-base? JUpload speaks a lot of languages and is able to learn any other.

With the help of properties-files, you can easily specify your own translation.

All language-files are located within JUpload's jar-file in: com/smartwerkz/jupload/classic/language/

The filenames of a language-file is either jupload_xx_YY.properties or jupload_xx.properties.

Language- (xx) und Country-names (YY) are standardized according to the i18n-standard, see

The files are simple text-files; each line has a keyword and a value. For example, the label of the "Add FIles"-Button within the GUI, is assigned like this:

Gui.Control.Add.Label=Add Files

While initialising, the Applet gathers information about the locale settings on client side and loads the corresponding language file automatically. You do not need to specifiy the language explicitly. It first tries to find a file that matches the user's language and country (jupload_xx_YY.properties). If that cannot be found, it will look for a file that matches only the language (jupload_xx.properties).

If no corresponding language file can be found, the default will be used: jupload.properties.

You can force all users to use one certain Locale, by setting the Locale-Parameter.

To create a custom translation, follow these steps:

  1. Copy one of the already existing language-files out of /dist/jupload: Jar-files (or archives) are simple zip-files and can be opened with any tool that supports zip-compression (eg winzip, winrar or winace for windows users).

  2. Rename it, according to the i18n-standard, mentioned above (eg jupload_de.properties for German, jupload_zh_ZH.properties for simplified Chinese, jupload_jp.properties for Japanese etc).

    Generally speaking, you should always have a language-file that matches the jupload_xx.properties-pattern so that people who speak the same language but live in a different country, from what you used as basis for the translation, would still see everything translated into their own language, even if some words, characters or grammar might be different (eg Austrians see everything translated in German and Taiwanese see everything translated in Chinese).

  3. Open the file with any text-editor and translate the messages on the right side of the equation sign ("=") of all lines. Do not change the values on the left side!

    If you want to write a message over several lines, add a backslash ("\") to the end of the line and the next line will just be appended to this line.

  4. Copy the file back into the language-folder within the jar-file.

  5. Resign the jar-file

All users with the corresponding language-settings or with the Locale-Parameter set to the language and country of the language-file, will now see all messages translated.

Note

Make sure to remove JUpload from the cache after changing the settings.

2. Debugging

If there are problems in the transmission or the functionality of JUpload, you should enable the debug mode to locate the source of the problem. Enabling the debug mode is done by using the Debug-Parameter.

Debug messages will be written into the Java Console. This console can be opened automatically, if set in the Java Plug-In in the Windows Control Panel. Alternatively you can open it from the tool-menu of your browser or from the Java-Icon in the taskbar (rightclick -> Open Console).

When encountering problems, you might often run into so-called Exceptions of different kinds which represent abnormal Program behavior or errors. One Exception often might cause other Exceptions in other places of the program where the actual initial Exception is always at the top. So if you encounter a problem and want to know what actually went wrong in the first place, look into the first line of the Exception's output.

For example, in the following exception, we found 2 Exceptions where the first line contains the actual cause of the problem: JUpload's class could not be found (see common problems):

load: class com.smartwerkz.jupload.classic.JUpload not found.
java.lang.ClassNotFoundException: com.smartwerkz.jupload.classic.JUpload
   at sun.applet.AppletClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.applet.AppletClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.applet.AppletClassLoader.loadCode(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
   at sun.applet.AppletClassLoader.getBytes(Unknown Source)
   at sun.applet.AppletClassLoader.access$100(Unknown Source)
   at sun.applet.AppletClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method) 

You can also add a Javascript-Handler for debug-information.

Java Console is helpful for debugging purposes

The Java Console Log Window can usually be shown through an option in your browser's Tool-menu. It can also be accesses by Java's system tray icon.

3. Verifying Data Integrity

To ensure that files are uploaded correctly, you can use hash codes to verify their contents. JUpload can calculate MD5 hashcodes of files and send it as Meta-Information.

To check the MD5 hashes on the server, you can use the corresponding Meta-Information sent by JUpload.

Warning

For performance reasons this feature is disabled by default and is NOT recommended to be used for files without outstanding importance!

Example 3.1. Veryifying Data Integrity using POST and PHP

$filename = $_FILES[0]['tmpname'];
$real_md5 = $_POST['files1_md5hash'];
$calc_md5 = md5_file($filename);
if ($calc_md5 != $real_md5) {
// Content got corrupted while or after upload
}
else {
// Hashes-values match: File is good
}

4. Resigning the jar File

The Certificate shown in the Security Dialog when the Applet is first loaded on the client's machine can be replaced by your own certificate.

You can use your own Code Signing Certificate and let a Certificate Authority (like Thawte, Verisign etc.) verify it.

The following steps are required to re-sign the jupload.jar file:

  1. Download and Install the Java 2 SDK from http://java.sun.com

  2. Either: Import your existing certificate into the Java Keystore:

    keytool -import -alias JUpload -file mycert.jks

    You will have to enter a new password for the keystore. The Keystore will secure the imported certificate with this password, so don't forget it. You will need it in the next step again.

  3. Or alternatively: To import an already existing certificate, you can create your own self-signed certificate. This won't be trusted by any root Certificate Authority and hence will be shown as "Untrusted" to the user.

    keytool -genkey -alias JUpload

    You will have to answer some questions (your name, company name etc.) and the certificate key will be generated.

  4. Use the jar signer utility to re-sign the JUpload-archive and all other archives that it uses (such as the HttpClient or the logging-archive).

    jarsigner jupload.jar JUpload
    jarsigner httpclient.jar JUpload
    etc...

Warning

In case that you signed the Applet and it still does not work. make sure that you a) really changed the signature of all needed jar-files (other jars, such as the skinlf-jar might also need to be (re-)signed. If it still does not work, make sure to remove all re-signed applets from the cache.

The following files are required by JUpload and need to be signed

Note

Signed versions of all these files are already included into the download-archive, which is available at our download-page.

Certain other archives, such as the SkinLF also need to be signed in order to work.

5. User-Authentication

Several ways of integrating User-Authentication

Basic- or NTLM (IWA) -Authentication

When using Apache, you can simply protect your upload-scripts and upload-directory by adding an .htaccess-file to restrict access (refer to your webserver's manual for more details).

JUpload supports Basic, Digest or NTLM (also known as IWA) -Authentication. The algorithm is set through the Upload.Http.Auth.Scheme-Parameter.

Activate User-Authentication by setting the Upload.Auth.UserAuthRequired-Parameter to true. The user is now asked to enter user-authentication before being able to upload any files. These settings can be changed by the user in Tools -> Settings -> User Login and can be locally stored (remembered) for future use.

You can also let JUpload automatically submit the login, by setting the Upload.Auth.AutoLogin-Parameter.

Warning

Never send any Login-Information to the user that the user himself is not supposed to know.

Example 3.2. Basic-Authentication Example


Use of cookies, get-values or post-values

If a user is already logged in on the website and you do not want to require him/her to login again, you can simply use session-cookies, query-values (get-values) or post-values to submit the current login-status. Therefore replace JUpload's Configuration-file by a script (for example using PHP). The script can then dynamically insert values of cookies or other.

In this case the Upload.Auth.UserAuthRequired-Parameter must then be set to false because it requires the user to actually enter user-information for webserver's default authentication (see above).

Example 3.3. Scripted Configuration

Note

Always make sure to add all information that you want the config-script to have, to the Config - URL. This is necessary eg. for sessions, since JUpload downloads the config-file in a seperate request which does not contain any further information.

Replace corresponding parameters in your configuration-file to dynamically submit the login-status (and/or any other kind of information) of the user. You have 3 different options to choose from:

Query (Get), Post, and Cookies

Thumbnail-uploads use their own set of parameters; make sure to also set those if you are making use of automatic thumbnail-creation.

Upload.Http.Method=post

# More parameters here...


# File parameters:

Upload.Http.Query=userid=<?php echo $user->getId(); ?>

Upload.Http.AdditionalPostFields=userid=<?php echo $user->getId(); ?>

Upload.Http.Cookies=<?php echo "phpsessid=$sid,myothercookie=$interestingInfo"; ?>


# Thumbnail parameters:

Upload.Thumbnails.Http.Query=userid=<?php echo $user->getId(); ?>

Upload.Thumbnails.Http.AdditionalPostFields=userid=<?php echo $user->getId(); ?>

Upload.Thumbnails.Http.Cookies=<?php echo "phpsessid=$sid,myothercookie=$interestingInfo"; ?>

Important

For some reason in PHP the linebreak directly following a <??> - tag is removed, thus you need to add an empty line after every script-insertion.

Warning

You cannot submit POST-Values with the PUT-Method.


6. Secure servers (SSL)

JUpload can connect to secure servers, using SSL. Secure server URLs must be prefixed with https://, indicating secure HTTP - protocol.

By default, JUpload accepts all SSL certificates automatically which might be considered a security risk in certain environments. This behavior can be changed by exchanging the TrustManager which determines wether or not certificates can be trusted. The TrustManager can be set through the Upload.SSLTrustManagerClass.

Note

Providing a custom TrustManager requires knowledge in Java. Smartwerkz offers additional services for customers who cannot meet this requirement - feel free to check back with us.

To implement a custom TrustManager, you need to follow these three steps:

  1. If you do not already have a TrustManager, you need to write one. A TrustManager has to implement the javax.net.ssl.X509TrustManager - Interface. The checkServerTrusted - Method is the method which decides wether or not a server can be trusted. With a call of the checkValidity - Method of each Certificate, you can ensure that the certificate is valid.

  2. Either add the class with all package-folders to an already existing jar-file or create a new jar-file which contains the class.

    If you need to access the local file-system, network-streams or certain other functions that are considered a potential security risk for web-applications, you also need to sign the jar-file.

    Add the jar-file to the list of archives.

  3. Set the Upload.SSLTrustManagerClass to the fully qualified classname of your TrustManager, including the package name.

Whenever JUpload is connecting to a secure server, it will use this TrustManager to determine wether or not the server's certificates are trustworthy. You can of course use GUI-interaction or similar to ask the user if the server is a trusted one or not.

7. Customizing with Parameters

Parameters and their types

You can find a list of all parameters in the appendix.

Parameters in JUpload's Config-File are simple key=value-pairs: The name indicates what the parameter is used for and the value overrides JUpload's default.

Every Parameter has a previously defined type. A type simply tells JUpload how the value should be understood.

There are 2 Special types: List and Map.

List

Values in a list are komma-seperated and have a certain type of their own. For example List (Files) stands for a List of Files.

Gui.ContextMenu.Files=ButtonA, ButtonB, ButtonC

Map

Values in a map are komma-seperated key-value-pairs in the format of key=value. For example Map(String, String) stands for a map with simple text-keys and text-values.

Keys of these map have non-unique keys which means that a map like myMap=x=1,x=2 contains 2 entries: x=1 and x=2.

Upload.Http.AdditionalHeaders=X-JUpload-UserID=henry, X-JUpload-Pass=secret

Upload.Http.Query=choice[]=1,choice[]=2

In the following table all other types are explained:

TypeDescriptionExample
StringSimple text. Can be restricted to only have certain values allowed. For example:
String (put, post)
In this case, the value can only be put or post.
Files.Convert.Format=jpg
StringPairA pair of 2 strings in the format: name=valueUpload.Auth.AutoLogin=username=password
IntegerA simple number in a range between -2 billion and +2 billionFiles.MaxImageSize=123456
IntegerRangeA list of numbers, where each number must be in a range between -2 billion and +2 billion. You can add multiple ranges seperated by commas. A single range can be either a single number or 2 numbers, combined with a dash "-" where the number to be expected would be in between.Upload.Http.ExpectedHeaders=200-204,210,220-234
LongA simple number in a range between negative and positive 9223372036854775800Upload.MaxTotalFileSize=8000000
DoubleA floating-point-number, such as 10.28MinJavaVersion=5.0
BooleanYes-or-no-switch: yes, 1, on and true can be used to enable this option and all other values would result into this option to be disabledDebug=no
FileThe location of a file in the local file system.Gui.FileChooser.DefaultDir=c:\me\important
URLThe location of a file located on the local file system or on an HTTP-server. Can be relative to the location of JUpload's embedding HTML-Page.Upload.URL.Action=http://mycompany.com/receive.php Upload.URL.Action=scripts/receive.php
ColorCSS-Formated-Color: A 6-digit hexadecimal value, representing the level of RGB-intensity (Red Green Blue). Can be preceeded by a "#".Gui.LF.Background=#EE99FF
LocaleA locale specifying language and cultural location in the pattern of:

language[,country[,variant]]

Anything but the language is optional.

The specification for language-, country- and variant-codes are according to the international standard i18n (see Localization).

Locale=en,US

Locale=en

FontA font in the pattern of:

name,style,size

The name can be the name of any font, supported by Java (any common one).

The style is a value between 0 and 3: 0 = Plain, 1 = Bold, 2 = Italic, 3 = Bold Italic

The size is the size of the font in points.

Gui.LF.Font=Arial,0,12
DimensionA size in the pattern of WidthxHeightGui.Views.Tree.MinSize=300x300
ImageThe URL of an Image-File (see URL-Type).SomeImage=media/background.gif
RegexFileFilterA filefilter that has a name and a regex-pattern, seperated by 2 vertical lines "||". If this filefilter is selected (eg in the FileChooser), its name will be displayed and only files that match the given regex-pattern will be displayed and added.Gui.FileChooser.Filter.Multi=Executables||(.*?\.exe)|(.*?\.com)
ExtFileFilterA FileFilter, consisting of a name, followed by 2 vertical lines ("||") and a list of Extensions. All Files that have one of the given extensions are ignored.MyFilter=Images||jpg,jpeg,.png,gif

See here for a ist of all parameters

Chapter 4. File-Reception - Scripts on your webserver

JUpload needs either webdav or a script using PHP, ASP or another language that is supported by your webbrowser to actually receive and save the sent files.

JUpload does not only send files but also sends so-called meta-information with every file, such as the name, its path, etc (see below for more info).

You can use two different methods for uploading the files: POST or PUT. The method being used can be changed, using the Upload.Http.Method - Parameter.

Script-files supporting both methods are already delivered with the download-package. You can easily configure them to do whatever your server needs to do.

1. Meta-Information from JUpload

JUpload sends so-called meta-information with every file (see Upload.Http.Meta.* - Parameters) and thumbnail (see Upload.Thumbnails.Http.* - Parameters) as shown in the table below.

When using the POST-Method, the file itself, as well as the sent meta-information are each one MIME-Multipart and each have a name-tag.

The name-tag of the file-parts consists of the value, specified in the Upload.Http.Meta.FileTag - Parameter, followed by a number (such as "files1").

The name-tag of the thumbnail-parts consists of the value, specified in the Upload.Thumbnails.Http.TagName - Parameter, followed by the number of the file it represents (such as "thumbnails1").

Each piece of meta-information about a file or thumbnail will be prefixed with the file's or thumbnail's name-tag and an underscore.

When using the PUT-Method, the meta-information of the file being sent is sent in the header. All meta-information-headers are prefixed with "X-JUpload" which means that this header is an "Extension for JUpload".

HTTP-headers do not support any encoding other than ASCII, which is why these information are URL-encoded, using JUpload's default encoding.

Here is a list of all available meta-information:

Suffix of part when using POSTName of header when using PUTDescription
_relativePathX-JUpload-RelativeFilenameThe filename and relative path of the file or (in case of a thumbnail) of the original within the Upload-Tree (eg. "/my documents/important/Laura.jpg").
_thumbnailX-JUpload-Thumbnail1 or 0, indicating wether it is a thumbnail of a file or an actual file.
_imageX-JUpload-Image1 or 0, indicating wether it is a valid image-file. Not sent for thumbnails.
_virtualX-JUpload-Virtual1 or 0, indicating wether the file is virtual or actually exists on the client's harddisk. Not sent for thumbnails.
_absolutePathX-JUpload-AbsolutePathThe absolut position of a file on the client's harddisk. Not sent for thumbnails.
_lastModifiedX-JUpload-LastModifiedThe date and time of the last modification of this file in seconds since the 01/01/1970.
_md5hashX-JUpload-MD5The MD5-Hash of the file. See here for more information.

2. Using the POST-Method

The POST-Method, similarly to emails, uses MIME-Multiparts which means that every POST-request can consist of one or more parts. One POST-request is one connection attempt. Everything that has been sent with one completed POST-request, will be saved. If a POST-Request fails, all files or parts of files that have been sent within the request are lost.

Every file as well as every bit of meta-information about the file represents one part. All sent files and their information (such as size and temporary name) are to be found in PHP's $_FILE array. All further information sent by JUpload can be found in the $_POST array. So we basically iterate over the $_FILE array, and find information about each file corresponding to its name in the $_POST array, as shown below.

There are 2 parameters for limiting size and amount of files being sent:

To set the maximum size of one post request, see the Upload.Http.MaxRequestSize - Parameter.

To set the maximum amount of bytes to be sent during one post request, see the Upload.Http.MaxRequestFileCount - Parameter.

The corresponding file jupload-post.php is delivered in the download-package.

2.1. Configuring PHP

When using POST with PHP, you must ensure that the server allows file-uploads. For that set the following values either directly in the php.ini or through the ini_set()-function.

file_uploads

Must be enabled, set it to 1

upload_tmp_dir

Must be set to a local folder on the server, to which the webserver has write-access. By default, the system's temporary directory is used, e.g. /tmp/

upload_max_filesize

Set this to the maximum filesize in bytes you wish to be permitted (should be greater than JUpload's Upload.Http.MaxRequestSize).

You can use the shorthands K,M and G for Kilobyte, Megabyte and Gigabyte: 1M is 1 Megabyte.

Warning

This defaults to 2 Megabyte in PHP! So you won't be able to upload files bigger than 2M with a standard php installation. Many hosting companies use a value of 8MB.

post_max_size

This should be set to a value larger than Upload.Http.MaxRequestSize

memory_limit

This setting also affects the file upload capabilities of PHP. Please ensure that this is set to a value high enough. The PHP Interpreter must be compiled with --enable-memory-limit to activate this limit. Set the value to -1 to disable memory limit.

max_execution_time

Set this to a value high enough for uploads to complete.

You can also disable the execution time limit in a single session by calling the function set_time_limit(0) at the beginning of a script.

max_input_time

Set this to a value high enough for uploads to complete.

When using Apache, some of these values can also be set in .htaccess files within your web folder. Check the PHP manual for details.

Additional information for PHP can be found at php.net.

To view your current PHP- and server- settings, use phpinfo() in your php script. This will print out your overall configuration of PHP and the webserver being used.

3. Using the PUT-Method

The PUT-Method supports resume of aborted file-transfers.

When using the PUT-Method, each file will be uploaded in its own PUT-request. It sends a HEAD-request before each file-upload to determine wether the file already exists. The server sends the so called Content-Length - Header in the response of each HEAD-request to tell JUpload how big the file already is. JUpload will then auto-resume the upload and only send the rest of the file.

In some cases you might want to save received files at a different location, in which case you need to send a customized Content-Length - Header for the HEAD-request in your own script. Some webservers (such as Apache) might automatically remove these header-information because they are considered faulty. In that case you need to use the X-Content-Length - Header which has the same syntax with a different name, to make sure that it won't be removed by the webserver. In case that the file to be uploaded does not exist, JUpload expects statuscode 404.

To activate the PUT-Method, you need to set Upload.URL.Action to an existing directory on your webserver.

To have this directory accept PUT-Requests, you can choose from one of the following options:

Using Webdav

The recommended and most simple way is: Activate webdav for the given Action-URL. You can read more about enabling and configuring webdav in your webserver's webdav-configuration or at the official homepage.

Using a custom script

Alternatively you let Upload.URL.Action point to the directory that you want your files to be saved to and redirect all PUT-Requests to a script-file of your choice: In our case, the JUpload-Receiver-Script.

When using Apache, in order to redirect all PUT-Requests, you need to add a "Script"-directive for the corresponding directory into your httpd.conf:

Example 4.1. Example for a Script-Directive for a certain Directory

<Directory "C:/htdocs/jupload/uploaded/">
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
    Script PUT C:/htdocs/jupload/scripts/php/jupload-put.php
</Directory>

The files will then be sent to this directory and saved by the script, that handles PUT-Requests for this directory.

The corresponding file jupload-put.php is delivered in the download-package.

When you are trying to save files to a location that is different from the directory, specified as the target in Upload.URL.Action, you also need to redirect all HEAD-requests to a custom script which sends the X-Content-Length - Header to JUpload to determine how much (if anything) of a file has already been received. There is no script-file for that delivered in the download-package because it is not recommended to save the files anywhere but in the pre-destined directory.


Both, Webdav and the delivered jupload-put.php already have builtin support for resuming files.

4. Configuring and customizing the upload-scripts

In case you are not using webdav, you can easily configure the scripts from the default scripts without changing them.

For that you can set all variables (must be global) which are defined in the corresponding config-file.

4.1. Set the variables

An overview over all customizable parameters for the receiving PHP-Scripts

Simply override these variables before including the either of JUpload's receive-scripts. Don't forget, they have to be global.

JUBaseListener $_ju_listener

Default: $_ju_listener = new JUDefaultListener();

If you want to work differently with received files(for example store the information in a database etc), create a new class that inherits from JUBaseListener or JUDefaultListener and override the corresponding methods. See the JUBaseListener-class for details.

Example 4.2. An example JUpload-Listener for a gallery (PHP)

/**
 * By simply overriding the JUDefaultListener, we can use all of its methods instead of re-define all of them when 
 * implementing JUBaseListener. 
 * In our case we only want to override the onReceived - method in order to add received images and thumbnails 
 * to the gallery which then eg inserts these information into a database.
 */
class JUGalleryListener extends JUDefaultListener {
	/**
	 * @var MyGallery $gallery
	 */
	var $gallery;

	function  JUGalleryListener($gallery) {
		$this->gallery = $gallery;
	}
	
	function onReceived($filepath, $relativePath, $isThumb) {
		$path = stripslashes($gallery->getPath() . $relativePath);
		
		if ($isThumb) {
			$this->gallery->addThumb($path);
		}
		else {
			$htmlpath = htmlspecialchars(basename($relativePath), ENT_QUOTES, "UTF-8");
			if ($this->gallery->addImage($path)) {
				echo "<div halign=left>Picture saved: $htmlpath</div>";
			}
			else {
				echo "<div halign=left>Could not save picture: $htmlpath</div>";
			}
		}
	}
}
 


string $_ju_uploadRoot

Default: $_ju_uploadRoot = dirname(__FILE__) . "/../../../uploaded/";

This is the location of the directory where files and thumbnails should be saved to.

By default points to the relative location of the /uploaded/ - folder that is delivered with the download-package.

Set it to an empty string if you do not want to save files and thumbnails within the same folder.

string $_ju_fileDir

Default: $_ju_fileDir = "files";

This is the location of the directory where files should be saved to within the $_ju_uploadRoot; basically at: "$_ju_uploadRoot$_ju_fileDir"

Set it to an empty string or null if you want to save all files directly under $_ju_uploadRoot.

string $_ju_thumbDir

Default: $_ju_thumbDir = "thumbnails";

This is the location of the directory where thumbnails should be saved to within the $_ju_uploadRoot; basically at: "$_ju_uploadRoot$_ju_thumbDir"

Set it to an empty string or null if you want to save all thumbnails directly under $_ju_uploadRoot.

int $_ju_maxSize

Default: -not set-

If set, determines the maximum size of files for PUT-Requests. The corresponding value for POST-Requests must be set through the php-configuration.

4.2. Embedd the receiver in your own script

Set the variables as described above and then simply include the corresponding receiver supporting your method: jupload-post.php or jupload-put.php:

Example 4.3. Customized JUpload-Receiver Example

<?
// Get the gallery according to the sid that was submitted via GET (Query)
$gallery = getGallery($_GET["sid"]);

// Let the script die and send a header that would tell JUpload when doing the HEAD-Request that this is an invalid Move
// This way it will not even try to upload invalid files.
if (!$gallery) {
  // The header-function tells JUpload, we have statuscode 403 (see validity-check for details).
  // It consists of the supported HTTP-Version, the status-code and an info-message which will be displayed in case
  // that this header was not expected by JUpload:
  header("HTTP/1.1 403 Invalid gallery");
  die("The gallery that you want to edit does not exist.");
}
?>

<HTML>
<BODY>

<?
// For safety reasons, mark the changed variables global, in case that we are not in the global scope here
global $_ju_uploadRoot, $_ju_listener;

// Change the upload-root
$_ju_uploadRoot = "/gallerysystem/images/$username/" . $gallery->getName();

// Set our own listener which adds corresponding database-entries of received files and thumbnails
$_ju_listener = new JUGalleryListener($gallery);

// include the receiver
require_once(DIR_JUPLOAD . "jupload-post.php");
?>
</BODY>
</HTML>


Chapter 5. Javascript and how to use it to enhance the JUpload-Experience

Use Javascript to replace JUpload's default User-Interface completely or to simply interact with it

1. What is the Javascript API?

The Javascript API is a common interface between Java and JavaScript, was developed by Netscape and is called LiveConnect.

With the help of LiveConnect, Java can access Javascript functions (and the page's DOM) and Javascript can access and control the Applet. JUpload uses both these features.

You can find the Javascript API-Reference in the appendix.

It allows you to control JUpload through JS as well as listen for all kinds of events.

In order to do so, you must set the "mayscript"-parameter for the Applet. With scripting activated, the Applet can now be accessed as document.JUpload in your page, where JUpload is the name of the Applet.

If javascript is activated and supported by the browserr, the init()-method will be called by JUpload upon start. Here you can initialize the interaction between JS and JUpload (eg. Registering listeners).

Javascript cannot access all of JUpload's functionality since some of them require special access-rights (eg accessing the local file-system or network-streams). These functions can only be accessed if explicitely defined by JUpload are now refered to as privileged functions.

All important supplied functions and listeners for controlling JUpload or obtaining information from it, are to be found in the next section and in the appendix.

Note

This API is using JUpload's own types (such as UploadClient, UploadEntity, UploadFile, UploadNode, UploadTree) which are explained in the JS-API-Reference. For further and more detailed explanations, pease consider JUpload's JavaDoc.

Important

Filenames in javascript do not support backslashes ("\") which is the default path-seperator under windows. You need to replace them with forward slashes ("/") before trying to add them to JUpload.

Example 5.1. JS-API HelloWorld-Example

<script language="javascript">
//
// This function is called by JUpload right after startup.
//
function init() {
    alert("JUpload started and says: Hello World!");
}
</script>

2. General and privileged Functions

Here is a list of general functions and those which require special access rights (eg when accessing the local file-system or a network stream).

  • js().takeScreenshot()

    Takes a screenshot.

  • js().clickAdd()

    Opens the filechooser

  • js().isUploading()

    Indicates wether an upload is currently in progress.

  • js().toggleUpload()

    Starts or stops the upload.

  • js().changeLanguage(language)

    Changes language into the given value. Language should be the iso-conform 2-character shortcut of the corresponding language. If the language is not recognized, the default one (english) will be used.

  • js().saveNodes(uploadNodes)

    Saves the given UploadNodes (array of UploadNode) and its children correspondingly to a path chosen by the user.

  • js().saveNodes(uploadNodes, directoryPath)

    Saves the given UploadNodes (array of UploadNode) and its children correspondingly to the given directory-path.

  • uploadTree()

    Returns the UploadTree which holds all files and folders that are to be uploaded

    Eg. can be used like this: document.JUpload.uploadTree().getFileCount()

  • gui()

    Returns the JUploadGui which represents the default Graphical User Interface

    Eg. can be used like this: document.JUpload.gui().statusMessage('some message')

3. Listeners

You can find a list of all listeners in the JS-API-Reference.

JUpload can easily inform Javascript about everything that it currently does. Simply register a listener for a set of events that you want to display on your webpage or use in any other form.

After registering a listener, whenever anything related to the corresponding listener happens, a js-function will be called in which you can describe what should happen. If an event of a registered Listener occurs whose function is not defined, a notice will be displayed in the console if debug-mode is enabled. If you do not care about certain events of a listener, just leave the function empty (you should define it though).

To register a listener, call the corresponding Register-function in your self-defined init() function which will be called right after JUpload has started. All Register-functions expect one parameter: A name which will then preceed all called functions of the listener (see example below).

When implementing a listener function, its name in js must consist of:

- the name of the Listener as defined in the Register-function

- an underscore ("_")

- the name of the listener-function, as described below

Caution

Called listener-functions will interrupt (block) the Applet until they return or finish.

Here is an overview over all supported events that you can listen to, using javascript:

Listener-nameRegister-functionRange of events
ResponseListenerjs().listenResponse(name)JUpload finished uploading and received a response from the server
UploadProgressListenerjs().listenUploadProgress(name)Everything related to the upload-progress, from initializing to finishing
UploadTreeListenerjs().listenUploadTree(name)All changes of the UploadTree, such as adding, removing, renaming or saving of nodes.
ViewSelectionListenerjs().listenViewSelection(name)The selection in the current UploadView has changed
DebugListenerjs().listenDebug(name)For log messages or unexpected program-malfunctions.
ResponseLinksListenerjs().listenResponseLinks(name)The user clicks on links in the ResponsePanel

The following list of all listener-functions and their parameters are described as in Java: Every object or entity also has a type which determines what operations can be used on it.

responseReceived(String response) // The function "responseReceived" has one parameter "response" which is of type "String"

The type of course needs to be left out when declaring the javascript function (see example below).

4. Javascript - Examples

Example 5.2. JUpload-JS-Listener example

You find a similar example with some further additions, in the index-js-text.html - file.

//
// This function is called by JUpload right after startup.
// Here we need to register all Listeners we want to use.
//
function init() {
    // The supplied parameter "UploadProgress" and "Reponse" is the prefix of all functions of the corresponding listener
    document.JUpload.js().listenUploadProgress("UploadProgress");
    document.JUpload.js().listenResponse("Response");
}

//
// Next we define all functions that are part of the listeners, registered in the init()-method.
// Every function-name consists of:
// - the name of the Listener ("UploadProgress" or "Response") as defined in the
// - an underscore ("_") 
// - the name of the listener-function
//
// ###################################################################################
// Listener: UploadProgress

function UploadProgress_initializing(client) {
    alert("Initializing upload...");
}

function UploadProgress_initialized(client) {
    alert("Upload initialized - Starting...");
}

function UploadProgress_failed(client, currentEntity, exception) {
    if (currentEntity != null) {
        var entity = "current file: " + currentEntity.getFullName();
    }
    else {
        var entity = "during connection-attempt";
    }

    alert("Upload failed (" + entity + "): " + exception);
}

function UploadProgress_dequeued(client, file) {
}

function UploadProgress_uploadingFileStart(client, file) {
    alert("Starting to upload: " + file.getFullName());
}

//
// In this function we can display the upload-progress.
// The UploadClient offers a lot more progress-information, as described
//
function UploadProgress_uploadingFile(client, file, count) {
    document.title = 'JUpload - Uploading "' + file.getFullName() + '" (' + client.getProgress().getTotalPercent() * 100 + '%)' ;
}

function UploadProgress_uploadedFile(client, file) {
    alert("File successfully uploaded: " + file);
}

function UploadProgress_uploadingThumbStart(client, file) {
    // not of interest right now - leave it empty
}

function UploadProgress_uploadingThumb(client, file, count) {
    // not of interest right now - leave it empty
}

function UploadProgress_uploadedThumb(client, file) {
    // not of interest right now - leave it empty
}

function UploadProgress_closed(client, succeeded) {
    if (succeeded) {
        alert("Upload finished successfully");
    }
    else {
        alert("User cancelled upload.");
    }
    document.title = "JUpload";
}



// ###################################################################################
// Listener: Response

//
// Function of the ResponseListener handling the server-response.
//
function Response_responseReceived(text) {
    alert("Server response: " + text);
    
    // document.getElementById("someDiv").innerHTML = text;  // Set the content of a div with the id = "someDiv"
}



Chapter 6. Updating from JUpload 0.89 and before

There have been severe changes and improvements between version 0.89 and 0.90. Mentioned below are the most important changes and information on how to resolve them.

1. Parameters

Important

Config-File

You can now use a config-file instead of defining all parameters in Applet's <param>-tags.

See Client-Side: Displaying the Applet for more information

Types

All parameters now have more determined types.

Refer to the chapter on parameters and types for exact details.

User interface and appereance

LookAndFeel, colors and general appereance

Parameters renamed - See here for more information

Texts and labels

Removed - Refer to the chapter on localization instead.

thumbWidth and thumbHeight

Replaced with the Gui.Views.Icon.MaxWidth - and Gui.Views.Icon.MaxHeight - Parameters

mainSplitpaneLocation and leftSplitpaneLocation

Removed - You can change the size of the UploadTreeView instead

captureScreenDelay

Removed - User can change it within GUI instead: See Gui.ContextMenu.* - Parameters

defaultAddDirectory

Renamed to Gui.FileChooser.DefaultDir

showPicturePreview

Renamed to Gui.FileChooser.Preview.Enabled

filechooserPreviewChecked

Renamed to Gui.FileChooser.Preview.Show

filechooserPreviewQuality

Renamed to Gui.FileChooser.Preview.Smooth

imageFileFilter

Renamed to Gui.FileChooser.Filter.Image

multiFileFilter*

Renamed to Gui.FileChooser.Filter.Multi

hideShowAll

Renamed and logic reversed (see Gui.FileChooser.Filter.All)

showServerResponse

Renamed to Gui.ServerResponse.Enable

showTabViews

Renamed to Gui.Views.Display

showThumbnails

Renamed to Gui.Views.Thumbs.Enabled

showSystemIcons

Renamed to Gui.Views.Icon.SystemIcons

showFilePaths

Renamed to Gui.Views.ShowPaths

autoSelectLastFile

Renamed to Gui.Views.AutoSelectAddedFiles

showSuccessDialog

Renamed to Gui.Status.ShowSuccessDialog

showStatusPanel

Renamed to Gui.Status.ShowPanel

hideAddButton, hideUploadButton, hideStopButton and hideRemoveButton

Replaced - see information on the Toolbar

showRealtimeResponse

Removed - Response will always be shown in realtime

captureScreen

Removed - see Gui.ContextMenu.*

disableContextMenu

Removed - see Gui.ContextMenu.* - Parameters

showErrorsOnAdd

Removed - The user can see a quick note of invalid files at the statusbar at the bottom and can open a list of all invalid files through the Tool-Menu.

See Gui.ContextMenu.* - Parameters

Upload

actionUrl

Renamed to Upload.URL.Action

usePutMethod

Replaced with Upload.Http.Method

authEnabled

Renamed to Upload.Auth.UserAuthRequired

usePresetAuthentification

Replaced with Upload.Auth.AutoLogin

additionalHeaders*

The "additionalHeader + x" - parameters are now replaced with the Upload.Http.AdditionalHeaders - Parameter

browserCookie

Replaced with Upload.Http.Cookies

PUTQueryString

Changed to Upload.Http.Query

fileTag

Renamed to Upload.Http.Meta.FileTag

useAbsolutePaths

Renamed to Upload.Http.Meta.AbsolutePath

sendLastModificationDate

Renamed to Upload.Http.Meta.LastModified (works now)

calculateMD5Hash

Renamed to Upload.Http.Meta.MD5

useRecursivePaths

The relative path of a file will always be sent (see Meta information)

maxFreeSpaceOnServer

Renamed to Upload.MaxTotalFileSize

maxNumberFiles

Renamed to Upload.MaxTotalFileCount

maxTotalRequestSize

Renamed to Upload.Http.MaxRequestSize

maxFilesPerRequest

Renamed to Upload.Http.MaxRequestFileCount

autostartUpload

Renamed to Upload.Autostart

PUTFragmentSize

Removed - unnecessary

checkResponse

Removed - unnecessary

fixJakartaBug

Removed - Fixed itself

overwriteContentType

Removed - unnecessary

useProxy

Removed - unnecessary

Proxy-settings can be set by the user in the applet.

skipNewlineAfterHeader

Removed - unnecessary

useFTPMethod

FTP is not supported yet. Also the protocol of the Target-URL will be determined automatically by JUpload.

Other

locale*

Replaced with the Locale - Parameter

checkJavaVersion

Changed to MinJavaVersion

preselectedFiles

Renamed to Files.Preselected

noDuplicates

Renamed to Files.Filter.Duplicates

noRecursion

Renamed to Files.Filter.Folders

convertImagesToFormat

Renamed to Files.Convert.Format

resizeImageMaxWidth

Renamed to Files.Convert.MaxWidth

resizeImageMaxHeight

Renamed to Files.Convert.MaxHeight

resizeInterpolationAlgorithm

Renamed to Files.Convert.InterpolationAlgo

improvedRendering

Removed, simply set the interpolation algorithm to activate improved rendering when converting images.

resizeWithMetadata

Renamed to Files.Convert.IncludeMetadata

dimensionFilter

Changed - see Files.Filter.MaxImageDimension

replaceDocument, completeUrl, errorUrl

Renamed to Upload.Complete.URL and Upload.Complete.ErrorURL correspondingly.

Alternatively you can use javascript-listener instead to manipulate the document when an event occurs (see here for examples)

targetFrame

Renamed to Upload.Complete.Target

Alternatively you can use javascript-listener instead to manipulate the document when an event occurs (see here for examples)

2. Javascript

The Javascript-API has severely changed. The old version's javascript-support was not nearly dynamic enough to compete with the new version's level of interoperability. Therefore basically all old functions have been replaced and/or changed, so that Javascripts written for an old version are not compatible with this version anymore.

In exchange you can now access every single element within JUpload and change its contents to a very high extent (see the new API-definition for more information).

It is also possible to listen to any event that is happening within JUpload, using the all new listener-API.

An example can be found here.

3. JUploadForm

The JUploadForm was the name of the form whose elements -if existing- would always be sent to the server with each Upload-Request. The name of the form can now be set in the configuration.

See the custom user-information - Feature for more details.

4. File-reception on the webserver

Server-side scripts for older versions of JUpload will still work with the new version. However there have been minor changes and additions:

PUT-Headers

Before all headers were sent by default; they now have to be activated through configuration.

See Meta-Information

Last modification-time + Thumbnail indication + Image indication

A file's last modification-time as well as an indicator for thumbnails and for images will now also be sent to the server.

See Meta-Information

Virtual files and absolute path

The absolute path of files will now only be sent if it is a non-virtual file and activated through configuration.

See Meta-Information

5. Other

New Features

JUpload has several new major features.

See here for more information

Plugins

Most builtin default Plugins also have changed.

Please refer to the Plugin-Chapter for further information.

A lot of new stuff

There have been many additions to the classic JUpload which are not listed here explicitely.

However you can find all information related to a certain aspect of JUpload in the corresponding chapters of this manual.

Enjoy the new Experience!

Chapter 7. Solving common problems

1. Applet not loading or not uploading

1.1. Loading Java Applet failed...

JUpload does not show up and you perhaps see an X with a white background and an error-message at the bottom of your browser:

This error will most certainly be accompanied by the following message in the console:

load: class com.smartwerkz.jupload.classic.JUpload not found.
java.lang.ClassNotFoundException: com.smartwerkz.jupload.classic.JUpload
   at sun.applet.AppletClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.applet.AppletClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.applet.AppletClassLoader.loadCode(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
   at sun.applet.AppletClassLoader.getBytes(Unknown Source)
   at sun.applet.AppletClassLoader.access$100(Unknown Source)
   at sun.applet.AppletClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method) 

In this case the Applet's archive could not be found at the destined location or could not be accessed for some other reason. Make sure that the archives are all at the right location.

If that did not work, at one point it seemed to help to simply restart the browser once (only seems to be required when updating the archieves very often in a row - thus only for the developer when playing around a lot).

1.2. SecurityException: Access Denied

If you get security warnings or have exceptions in the Java Console like the following one, the Signature of the jar file might be broken, or you have declined the Certificate in the Security Dialog.

In this case please reload the page and accept the certificate. If it still says "Access Denied", one of the Jar-Files that JUpload uses, might need to be signed again or Javascript is trying to execute a method it is not allowed to execute (see Javascript-Support).

				java.security.AccessControlException: access denied (java.util.PropertyPermission javaplugin.proxy.config.list read)
				at java.security.AccessControlContext.checkPermission(Unknown Source)
				at java.security.AccessController.checkPermission(Unknown Source)
				at java.lang.SecurityManager.checkPermission(Unknown Source)
				at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
				at java.lang.System.getProperty(Unknown Source)
			

1.3. Invalid Settings: Could not parse parameter

Important

If JUpload cannot read a Parameter or Config-Settings correctly, it will not start and instead show an error-message in the console and an error will popup:

In the configuration you will have the following entry:

Files.MaxImageSize=123ef

Information to be found in the Java-Console (see Debugging):

Parsing parameters for class com.smartwerkz.jupload.classic.JUpload:
java.lang.RuntimeException: com.smartwerkz.jupload.classic.config.params.ParameterException: Could not parse parameter "Files.MaxImageSize" - Cannot convert "123ef" to type "Integer" (class java.lang.NumberFormatException: For input string: "123ef").

This would be the first 2 lines of the error-output. Be sure to always scroll up to find the real source of the problem in case of an error.

In this example-case, you can simply go to your configuration file (or applet-tag) and change the value for the parameter Files.MaxImageSize to a correct number.

2. Look&Feel (L&F) does not change or show up

In case that JUpload does not appear in your Look-and-Feel as expected, you will usually see an error in the console, such as:

java.lang.ClassNotFoundException: my.special.LookAndFeel

In this case the LookAndFeel's classname is either incorrect or the jar-file was not added to the Applet's archive-tag (refer to Step 2 and 3 of the instructions for custom L&Fs).

Alternatively you can use the other Gui.LF.* - Parameters to do some rudimentary changes to colors, borders and the font being used.

3. Cannot redirect

JUpload does not support automatic redirects. If the server sends a redirect-request, you might encounter this error-message:

Redirect requested but followRedirects is disabled

Be sure to always point to the right location and do not redirect, by sendig the Location - Header to JUpload.

From a developer's point of view, assuming that the action-URL is correct and has not been moved to another location, a redirect is only required if the client has an invalid status for the given URL (eg. the user is not logged in but wants to access a restricted area).

To avoid this problem, simply make sure that JUpload always submits all needed information that are needed to verify the correct status for the action-URL. Sessions might not work, if you do not use cookies, query- or post-values to verify the session. See the chapter on user-verification for details.

4.