Show total file size on progress bar

Upload core product.
jecsp
Posts: 12
Joined: Mon Feb 23, 2009 7:54 am

Show total file size on progress bar

Post by jecsp »

Hi,

Is it possible to show the total file size on the progress bar after selected the files?

Thanks!

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

Re: Show total file size on progress bar

Post by support »

No sorry. With JBatchUpload you can see file size of each file and total files to upload:
http://www.jfileupload.com/products/jba ... index.html

jecsp
Posts: 12
Joined: Mon Feb 23, 2009 7:54 am

Re: Show total file size on progress bar

Post by jecsp »

Hi,

Any comment if I still need to show out the total file size on my web page (not on progress bar) after selected the files? just need to let user notice their total uploaded file size so that they will know whether the uploaded file size is exceeding the max file size, or can I add an action event to check the total file size after click on the open button? This is very common requirement for upload file task. Please assist. Thanks!

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

Re: Show total file size on progress bar

Post by support »

We may have a feature in JBatchUpload that could fit to your need.

First you need to install JFileUpload + JBatchUpload + JSAPI (in add-ons sections).
Then uncomment the following line in i18n_pane.properties of JBatchUpload:

Code: Select all

# Misc
#js.notification.selection=JSSelectionInfo
In the HTML file that contains JavaScript functions, add a new function:

Code: Select all

function JSSelectionInfo(amount, size)
{
    alert(amount);
    alert(size);
}
Then when you select files in JBatchUpload, you get notified about total amount of files with full size. See screenshot below:
jsapi.jpg
New JavaScript function
(78.16 KiB) Downloaded 230 times
Does it help ?

jecsp
Posts: 12
Joined: Mon Feb 23, 2009 7:54 am

Re: Show total file size on progress bar

Post by jecsp »

Hi,

Thank you for your reply. Please read my problem below:

1) I'd downloaded the JSAPI. But I can't see the JSSelectionInfo row and startUpload() row on the applet_http_jsapi.html as the jsapi.jpg that you attached. Please advice.

2) After installed, my applet can't load due to this error

java.lang.SecurityException: class "jfileupload.upload.client.JSMApplet"'s signer information does not match signer information of other classes in the same package

My javascript as below:

Code: Select all

document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.JSMApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="batch_upload_prod_img/lib/jfileupload.jar,batch_upload_prod_img/lib/httpimpl.jar,batch_upload_prod_img/lib/chttpclient.jar,batch_upload_prod_img/lib/clogging.jar,batch_upload_prod_img/lib/batchui.jar,batch_upload_prod_img/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="url" VALUE="http://localhost/admin/batch_upload_prod_img/ctBatchUploadProcess.jsp">');
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="param2" VALUE="merchant_id">');
document.writeln('<PARAM NAME="value2" VALUE="'+ merchant_id + '">');
document.writeln('<PARAM NAME="transferui" VALUE="jfileupload.transfer.client.edesign.BatchTransferUI">');
document.writeln('<PARAM NAME="transferuiresources" VALUE="batch_upload_prod_img/i18n_pane">');
document.writeln('<PARAM NAME="resources" VALUE="batch_upload_prod_img/i18n_bar">');
document.writeln('<PARAM NAME="resetprogressbar" VALUE="true">');
document.writeln('<PARAM NAME="mayscript" VALUE="true">');
document.writeln('<PARAM NAME="mode" VALUE="http">');
document.writeln('<PARAM NAME="whitelist" VALUE="*.jpg,*.jpeg,*.gif,*.png">');
document.writeln('<PARAM NAME="post" VALUE="http://localhost/admin/page.jsp?fwbPageId=ctBatchUploadReturn">');
document.writeln('<PARAM NAME="postparameters" VALUE="extra">');
document.writeln('<PARAM NAME="forward" VALUE="http://localhost/admin/page.jsp?fwbPageId=ctBatchUploadReturn">');
3) I following your instruction that added the javascript on the html page and uncomment the line on i18n_pane.properties. Is it suppose to prompt the amount and size after selected the files? but nothing happen after I selected the files. Please advice.

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

Re: Show total file size on progress bar

Post by support »

1) You have to add this JavaScript function (copy/paste the code I've provided) because it is not available with basic JFileUpload, it only works with JBatchUpload. Below a full sample of HTML and JavaScript files:
sample.zip
Ready-to-use HTML and JavaScript
(3.28 KiB) Downloaded 1480 times
2) Are you using JFileUpload 2.3 + JBatchUpload 2.3 + JSAPI 2.3 ?
Try to clean your Java cache too: Start->Control Panel->Java->First tab->Delete all temporary files->Apply.

Does the full code I've provided help ? It should display the amount of files + size in the form when you select files.

jecsp
Posts: 12
Joined: Mon Feb 23, 2009 7:54 am

Re: Show total file size on progress bar

Post by jecsp »

Hi,

Thanks for the previous support. I have 2 more questions below:

1) On the JSSelectionInfo, I will check the total file size and max file size, if the total file size is over, then I will prompt an alert and disable the upload button. Please advice on how to disable the upload button, and activate back the button. If jfileupload can't cater this now, how can I check the file size and prompt the error to user?

2) How can I show out the error message? If I want to do some additional checking and hit the error on the process.jsp

Please reply as soon as possible. Thank you!

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

Re: Show total file size on progress bar

Post by support »

For #1, try <PARAM NAME="maxsize" VALUE="amountinbytes">. The applet will display an error message if total size is > maxsize. I'm going to see how to add the ability the grey out the button from JavaScript.

jecsp
Posts: 12
Joined: Mon Feb 23, 2009 7:54 am

Re: Show total file size on progress bar

Post by jecsp »

Hi,

I added the line <PARAM NAME="maxsize" VALUE="amountinbytes">, and add alert on the JSTransferFailed but nothing prompt out when I testing on file size.

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

Re: Show total file size on progress bar

Post by support »

I've the solution to grey out all buttons from JavaScript in 2.4 beta. Please drop an email to support(at)jfileupload(dot)com and I will provide it.

Post Reply