- Parameters for FTP upload -
Here is the list and the meaning of all JFileUpload parameters for FTP upload. You will also find HTML/JavaScript sample for Applet definition. Notice that there are two types of parameter: regular and extra.
"dummy=test" regular parameter is setup through <PARAM NAME="dummy" VALUE="test">. dummy=test extra parameter number five is setup through <PARAM NAME"param5" VALUE="dummy"> and <PARAM NAME"value5" VALUE="test">.
JFileUpload regular parameters |
Parameters |
Description and sample |
Mandatory |
url |
FTP server URL that will process the upload.
For instance, ftp://ftp.mycompany.com |
yes |
mode |
This parameter allows to select transport protocol.
For FTP upload it must be "ftp". |
yes |
maxsize |
This parameter allows to limit upload size (in
bytes). For instance, to avoid end-user to send
more than 1MB file, use maxsize=1048576. Default
maxsize is -1. It means unlimited upload size. Note
that 1MB=1024*1024=1048576 bytes. |
no |
maxfiles |
This parameter allows to limit number of files
to upload. Default maxfiles is -1. It means unlimited
files. |
no |
whitelist |
This parameter allows to filter filenames to upload (*.doc, *.exe,*.gif,*.pdf ...). For instance, to allow end-user to upload microsoft excel files only, use whitelist="*.xls". For both gif and jpeg use whitelist="*.gif,*.jpg,*.jpeg". |
no |
blacklist |
This parameter allows to forbid filenames to upload (*.exe, *.zip,*.mp3 ...). For instance, to disallow end-user to upload microsoft executable files, use blacklist="*.exe". Note that if you use blacklist then you cannot use whitelist parameter. |
no |
policy |
This parameter allows to modify JFileUpload
behavior when a file to upload does not match to
whitelist or maxsize. Default value is "abort",
it means that upload won't proceed. "ignore"
value means upload will proceed and unmatching files
will be ignored. |
no |
folderdepth |
This parameter allows to set a max depth for directories
and subdirectories uploads. Default is 0, it means
to not recurse subdirectories. -1 means unlimited. |
no |
resume |
This parameter allows to resume broken uploads. Values could be "true" or "false". Default is false. An upload is considered broken if remote file already exists and size < local file size.
See FAQ to learn how it works. |
no |
overwrite |
This parameter allows to define overwrite policy for duplicate file on remote server. Values could be :
"true": Allow overwrite.
"false": Return an error message for duplicate uploads.
"indexrename": Rename duplicate upload such as file_1.zip
"timerename": Rename duplicate upload such as file_mstime.zip
Default value is true. See FAQ to learn how it works. |
no |
hiddenfile |
This parameter allows to "accept" or
"deny" hidden files for upload. Default
value is "accept". |
no |
template |
This parameter allows to rename files to upload with a given template. Value could be any combination of :
":filename:" => Selected filename.
":name:" => Selected name.
":shortname:" => Selected short name.
":extension:" => Selected extension.
":timestamp:" => Unix-like (epoch) timestamp.
":identifier:" => Auto increment integer starting at zero
or value defined by identifierinit parameter.
For instance,
template="test_:timestamp:_:name::extension:"
Value could be a regular expression followed by a string that will replace characters matching to the regular expression:
":regex=YourRegExpHere:ReplaceString:"
For instance, if you want to replace all non ASCII characters and punctuation by "_" then value of template will be:
":regex=[^a-zA-Z0-9_\\-\\.]:_:".; If you need to apply template to folders in addition to files then add templatescope="path" parameter. |
no |
ziponfly |
This parameter allows to zip file on-fly before uploading. It reduces bandwidth usage but it could affect client performance because of compression process.
Values could be :
"true" or "zip" => ZIP compression
"gzip" => GZIP compression.
".zip" or ".gz" extension will be appended to uploaded filename. Default value is "false". Learn more in FAQ.
For overall (one ZIP archive) compression, see tutorial. |
no |
zipignorelist |
When ziponfly is enabled, this parameter allows to setup filenames to not zip. For instance, zipgnorelist="*.zip,*gif". |
no |
zipmaxsize |
This parameter allows to limit upload size (in bytes) of compressed file. For instance, to avoid end-user to send more than 1MB file, use zipmaxsize=1048576. Default zipmaxsize is -1. It means unlimited. |
no |
startdir |
This parameter allows to setup a local directory, instead of user's home, when using file browser (e.g. startdir="c:/tmp")
|
no |
authentication |
Setup authentication="auto" if you want to prompt end-user for FTP login/password instead of passing username and password in applet parameters.
Default value is "disabled".
|
no |
forward |
This parameter allows to redirect to another URL
once upload is completed. You could select the target
frame through forwardtarget parameter (see below).
For instance, forward="http://yourserver.com/redirect.php" |
no |
forwardtarget |
When forward parameter is enabled, this parameter
allows to redirect URL to a given browser frame.
Use _blank for new window. |
no |
forwardparameters |
When this parameter is set to true, JFileUpload
appends uploaded filenames to redirect URL. For
instance, "?filename1=foo1.txt&filename2=foo2.zip
..."
|
no |
post |
This parameter allows to send HTTP POST request
once upload is completed. See FAQ to learn how it works.
For instance, post="http://yourserver.com/process.php" |
no |
postparameters |
This parameter allows to pass filenames uploaded
in POST request above.
"true" means "filename1=foo1.txt&filename2=foo2.zip..."
"long" means "filename1=/home/usr1/foo1.txt&filename2=..."
"extra" is same as long with filesize, last modified timestamp and extra parameters. See tutorial to learn more. |
no |
retry |
This parameter allows to retry current upload when underlying socket fails (bad networks, connection timeout). For instance, to enable 3 retry attempts => retry="3" |
no |
retrydelay |
This parameter allows to setup delay in seconds between each retry attempts. Default is 2 seconds. |
no |
preferences |
Use preferences="true" to enable persistent preferences such as last directory opened. |
no |
timeout |
This advanced parameter allows to modify underlying
socket timeout in milliseconds. |
no |
socksproxyhost |
This advanced parameter allows to setup SOCKS
proxy host.
|
no |
socksproxyport |
This parameter allows to setup SOCKS proxy port. |
no |
resources |
This advanced parameter allows to select a custom
properties file including all resources (messages,
errors, menu, items, colors) to be displayed. See
internationalization section in FAQ to learn more. |
no |
localeresources |
This advanced parameter allows to load resources based end-user locale/country code. Default is true. |
no |
verbosemode |
This advanced parameter allows enabling applet traces for debugging purposes:
"debug" => Debug traces are displayed in Java console.
|
no |
|
JFileUpload extra parameters |
Extra
parameters |
Description and sample |
Mandatory |
paramX and valueX
pair |
Additional
parameters could be passed to FTP server through
paramX, valueX (with X in [1,16]). For instance
to pass anonymous login then use param1=username,
value1=anonymous. See below for all supported extra
parameters. |
no. |
username |
This parameter allows to pass username when connecting
to FTP server. |
no |
password |
This parameter allows to pass password when connecting
to FTP server. |
no |
account |
This parameter allows to pass initial remote directory
name when connecting to FTP server. For instance,
param3=account and value3=dirname/subdir. Folder
must be relative to FTP root folder. |
no |
accountcreation |
Depending on account parameter above, this parameter allows to enable/disable initial remote directory creation on FTP server if it is not available. For instance, param4=accountcreation and value4=true. Default value is false. |
no |
accountcreationchmod |
This parameter allows to run a unix chmod command on the folder created with account and accountcreation parameters. For instance, to set all unix permissions to rwx then param5=accountcreationchmod, value5=777. |
no |
accountpwd |
This parameter allows to send a PWD command to FTP server before uploading. It uses the returned working directory to prefix CWD commands. |
no |
relativefilename |
When this parameter is set to true, JFileUpload
will try to create folders and subfolders structure
on FTP server when uploading directories. Default
value is "false". Learn more in FAQ. |
no |
pasv |
This parameter allows to enable/disable passive
mode for FTP commands. To enable PASV mode then
setup value to true. For instance, param4=pasv,
value4=true. Default value is false. |
no |
sitecommand |
This advanced parameter allows to pass a SITE
ftp command after connection and authentication. |
no |
deleteonfail |
This parameter allows to delete uncomplete file on FTP server when upload is cancelled or failed. Default value is "false". |
no |
chmodafterupload |
This parameter allows to run a unix chmod command for each file uploaded. For instance, to set all unix permissions to rwx then param5=chmodafterupload, value5=777. |
no |
resumecommand |
This parameter allows to send an APPE command when resuming. It helps for FTP servers that don't support REST + STOR commands. Enable it with resumecommand="append". |
no |
remoteverification |
This parameter allows to enable/disable remote host connections verification. It should help when getting "Host attempting data connection ip address is not same as server" issue.
Disable verification with remoteverification="false". Default is value is "true". |
no |
commandmonitor |
This parameter allows to send NOOP command periodically while uploading. It can avoid FTP command channel timeout for long upload. Such feature is not supported by all FTP servers. Period is in seconds, for 5 minutes use commandmonitor="300". |
no |
ftpsmode |
This advanced parameter allows to select FTPS explicit or implicit TLS/SSL connection mode. Value could be :
auth_tls : AUTH TLS command is sent before SSL handshake.
auth_ssl : AUTH SSL command is sent before SSL handshake.
ssl_connect : Connection starts with a SSL handshake.
Default value is auth_tls when FTPS is enabled. |
no |
ftpsprot |
This advanced parameter allows to disable/enable channel protection on FTPS transfer. Values could be :
prot_p : Protection channel enabled.
prot_c : Protection channel not enabled.
Default value is prot_p when FTPS is enabled. |
no |
ftpsession |
This advanced parameter allows to not close FTP connection after transfer. Next transfer will reuse the existing FTP session. Enable it with ftpsession="true" and add the following regular parameter: concurrency="1" |
no |
|
JFileUpload HTML and JavaScript declaration sample |
Below the code you need to copy/paste in your HTML source to use JFileUpload applet:
<!-- JFileUpload Applet : Begin copy/paste -->
<script src="applet_ftp.js"></script>
<!-- JFileUpload Applet : End copy/paste --> |
Copy applet_ftp.js javascript file in the same folder as your HTML file. Setup parameters (according to table above) in blue. Notice that all parameters need to be setup twice (it allows cross-browsers support).
<!--
var _info = navigator.userAgent;
var _ns = false;
var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 &&
_info.indexOf("Win") > 0 && _info.indexOf("Windows
3.1") < 0);
if (_info.indexOf("Opera") > 0) _ie = false;
var _ns = (navigator.appName.indexOf("Netscape")
>= 0 && ((_info.indexOf("Win")
> 0 && _info.indexOf("Win16") <
0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux")
> 0) || (_info.indexOf("AIX") > 0) ||
(_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX")
> 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5")
>= 0));
if (_ie == true) {
document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="250" HEIGHT="250" NAME="fileupload" codebase="http://java.sun.com/update/1.6.0/jinstall-6u34-windows-i586.cab#Version=6,0,0,4">');
}
else if (_ns == true && _ns6 == false) {
// BEGIN: Update parameters below
for NETSCAPE 3.x and 4.x support.
document.write('<EMBED ');
document.write('type="application/x-java-applet;version=1.6"
');
document.write('CODE="jfileupload.upload.client.MApplet.class"
');
document.write('JAVA_CODEBASE="./" ');
document.write('ARCHIVE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar"
');
document.write('NAME="fileupload" ');
document.write('WIDTH="250" ');
document.write('HEIGHT="250" ');
document.write('url="ftp://localhost" ');
document.write('param1="username" ');
document.write('value1="anonymous" ');
document.write('param2="password" ');
document.write('value2="something@somewhere.com" ');
document.write('mode="ftp" ');
document.write('scriptable=true ');
document.writeln('pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED>');
// END
}
else {
document.write('<APPLET CODE="jfileupload.upload.client.MApplet.class"
JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar" WIDTH="250" HEIGHT="250" NAME="fileupload">');
}
// BEGIN: Update parameters below
for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA,
NETSCAPE 6+ support.
document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.MApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar">');
document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.6">');
document.writeln('<PARAM NAME="scriptable"
VALUE="true">');
document.writeln('<PARAM NAME="url"
VALUE="ftp://localhost">');
document.writeln('<PARAM NAME="param1"
VALUE="username">');
document.writeln('<PARAM NAME="value1"
VALUE="anonymous">');
document.writeln('<PARAM NAME="param2"
VALUE="password">');
document.writeln('<PARAM NAME="value2"
VALUE="something@somewhere.com">');
document.writeln('<PARAM NAME="mode"
VALUE="ftp">');
// END
if (_ie == true) {
document.write('</OBJECT>');
}
else if (_ns == true && _ns6 == false) {
document.write('</NOEMBED></EMBED>');
}
else {
document.write('</APPLET>');
}
//--> |
|