calling information via javascript

Upload core product.
dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

calling information via javascript

Post by dj_hands3 »

Hello i know there is a way of calling the file size via javascript e.g. onclick="this.form.field3a.value=document.fileupload.size() but what else i need is the file size, is there a seperate javascript function I could call to get the size of the file uploading?

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: calling information via javascript

Post by support »

If you install the JSAPI, you have a callback with file size:

Code: Select all

function JSTransferStarted(filename, filesize)
{

}
Could it help ?

The JSAPI is available at:
http://www.jfileupload.com/products/tools/index.html

dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

Re: calling information via javascript

Post by dj_hands3 »

hello do you have the file applet_ftp_jsapi.js as its mising from the zip file and only shows the http version, i tried modifying my exsisting ftp version but get errors iv copied the jsapi.jar in to the lib folder so its just the applet_ftp_jsapi.js i need to modify? i tried this
<!--
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.4.2/jinsta ... on=1,4,0,0">');
}
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.4" ');
document.write('CODE="jfileupload.upload.client.JSMApplet.class" ');
document.write('JAVA_CODEBASE="./" ');
document.write('ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar,lib/jsapi.jar" ');
document.write('NAME="fileupload" ');
document.write('WIDTH="250" ');
document.write('HEIGHT="250" ');

document.write('paramfile="uploadfile" ');
document.write('param1="todo" ');
document.write('value1="upload" ');
document.write('mode="ftp" ');
document.write('scriptable=true ');
document.write('mayscript=true ');
document.write('resources="i18n" ');
document.write('whitelist="*.mp3" ');
document.write('param5="account" ');
document.write('value5="htdocs/mixes/" ');
document.writeln('pluginspage="http://java.sun.com/products/plugin/ind ... "><NOEMBED>');
// END
}
else {
document.writeln('<APPLET CODE="jfileupload.upload.client.JSMApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar,lib/jsapi.jar" WIDTH="250" HEIGHT="250" NAME="fileupload" MAYSCRIPT>');
}
// BEGIN: Update parameters below for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA, NETSCAPE 6+ support.
document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.JSMApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar,lib/jsapi.jar">');
document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
document.writeln('<PARAM NAME="scriptable" VALUE="true">');
document.writeln('<PARAM NAME="mayscript" VALUE="true">');

document.writeln('<PARAM NAME="paramfile" VALUE="uploadfile">');
document.writeln('<PARAM NAME="param1" VALUE="todo">');
document.writeln('<PARAM NAME="value1" VALUE="upload">');
document.writeln('<PARAM NAME="mode" VALUE="ftp">');
document.writeln('<PARAM NAME="resources" VALUE="i18n">');
document.writeln('<PARAM NAME="whitelist" VALUE="*.mp3">');
document.writeln('<PARAM NAME="param5" value="account">');
document.writeln('<PARAM NAME="value5" value="htdocs/mixes/">');


// END
if (_ie == true) {
document.writeln('</OBJECT>');
}
else if (_ns == true && _ns6 == false) {
document.writeln('</NOEMBED></EMBED>');
}
else {
document.writeln('</APPLET>');
}
//-->
but get errors this basic: error:

jfileupload/upload/client/MApplet.
java.lang.NoClassDefFoundError: jfileupload/upload/client/MApplet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: jfileupload.upload.client.MApplet
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 19 more
Caused by: java.io.IOException: open HTTP connection failed:http://www.my-site.co.uk/jfileupload/up ... plet.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 23 more
Exception: java.lang.NoClassDefFoundError: jfileupload/upload/client/MApplet
Ignored exception: java.lang.NoClassDefFoundError: jfileupload/upload/client/MApplet

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: calling information via javascript

Post by support »

Here is the sample for JFileUpload FTP + JavaScript API:
applet_ftp_jsapi.zip
(2.88 KiB) Downloaded 1100 times
Does it help ?

dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

Re: calling information via javascript

Post by dj_hands3 »

still getting errors so I have emailed you a zip of my current files.

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: calling information via javascript

Post by support »

You have the same error with our online demo ?
You have a problem of Java cache. Try to clean it:
Start->Control Panel->Java->First tab->Delete temporary files->Apply
Then clean browser cache, close all browser windows and try again.

dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

Re: calling information via javascript

Post by dj_hands3 »

Hello I have cleared all caches java and IE temp folder, still no luck.To simplify the matter could you do a zip file that includes all files that shows me this working as i have had no luck and is crucial I get this working for my site. Thanks

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: calling information via javascript

Post by support »

Sure.
JFileUpload-FTP-JSAPI-2.4Beta.zip
(343.21 KiB) Downloaded 1110 times

dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

Re: calling information via javascript

Post by dj_hands3 »

Thank you very much support team this has enabled me to sort it out nice 1 for the zip file! :D

dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

Re: calling information via javascript

Post by dj_hands3 »

Thanks for your ftp version could it be possible to upload a zip file of a proven working demo of this is http mode as I having difficulty confirguring at the moment, regards sean

Post Reply