JFileUpload provides two parameters "post" and "forward" with similar behavior:
- "forward" is a real redirect to a web page. It drives the underlying browser to display the URL setup in this parameter:
<PARAM NAME="forward" VALUE="http://server.com/page.php">
The URL must be absolute and not relative. If you need to pass your own parameters then just append them as any URL parameter:
<PARAM NAME="forward" VALUE="http://server.com/page.php?p1=abc&p2=123">
The page.php will receive an HTTP GET request and the generated HTML will be displayed in the browser.
- "post" won't redirect to the specified URL. It only sends an HTTP POST request and discards the HTML response:
<PARAM NAME="post" VALUE="http://server.com/path/script.php?p1=abc&p2=123">
The URL must be absolute and not relative. "post" is mainly used to send status silently about upload on server-side without any end-user interaction. "forward" is really to redirect web browser to another page.
Note that both "post" and "forward" could be used together. "post" will execute first followed by "forward". Two others parameters work with "post" and "forward": "postparameters" and "forwardparameters". They have exactly the same behavior. They allow to pass details about upload such as filename, filesize, folder structure and timestamp. Values could be:
- true: It passes each filename uploaded as: filename1=file1.ext&filename2=file2.ext...
- short: It passes each filename uploaded as: filename=file1.ext;file2.ext
- long: It passes each filename with absolute path selected by end-user as:
- longer: It passes each filename with absolute path and filesize as:
filedate is milliseconds from epoch (January 1st, 1970). For instance, 1191938466593 means October 09th, 2007, 3:01:06 PM GMT+1
- extrarelative: It passes each filename with relative path and extra parameters. It could be useful when you need to know the relative folder structure that has been uploaded:
To make it works you need to setup folderdepth, relativefilename and notifyrelativefilename parameters as following:
<PARAM NAME="folderdepth" VALUE="-1">
<PARAM NAME="param3" VALUE="relativefilename">
<PARAM NAME="value3" VALUE="true">
<PARAM NAME="param4" VALUE="notifyrelativefilename">
<PARAM NAME="value4" VALUE="true">
<PARAM NAME="post" VALUE="http://server.com/script.php">
<PARAM NAME="postparameters" VALUE="extrarelative">
Each upload detail is then available on server-side as it was sent by a simple HTML form. It means that they can be read with standard API for HTTP GET or POST.