how can I get the upload file size?

asked 2007-04-23 05:55:21 +0800

admin gravatar image admin
18691 1 10 129
ZK Team

Orignial message at:

By: jimmyzou

Media media = Fileupload.get();
but the media's API do not provide the method about how to get the uploaded file's size?
Is ther anyone can help me ?
thkx a lots.

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2007-04-23 09:59:13 +0800

admin gravatar image admin
18691 1 10 129
ZK Team

Orignial message at:

By: sousa1981

I am using apache commons io jar to convert:

import org.apache.commons.io.IOUtils;

Media media = Fileupload.get();
byte[] uploadedfile = IOUtils.toByteArray(media.getStreamData());
System.out.println("FILESIZE: " + uploadedfile.length);
System.out.println("FORMAT: " + media.getFormat());

As you can see, the method IOUtils.toByteArray only convert the inputstream to byte array, then, you can write your own method to do that.

Marcos de Sousa

link publish delete flag offensive edit

answered 2016-09-20 10:25:11 +0800

psingh gravatar image psingh flag of India
963 8

If I am going to upload 1 gb file and using the below code

byte[] uploadedfile = IOUtils.toByteArray(media.getStreamData());

It is taking too much time on this line even hangout my application.

Is there any other way to get the uploaded file size in limited time?

link publish delete flag offensive edit

answered 2016-09-20 10:49:34 +0800

Darksu gravatar image Darksu
1991 1 4

Hello psingh,

I answered a similar question that you posted at the following url:


Best Regards,


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2007-04-23 05:55:21 +0800

Seen: 393 times

Last updated: Sep 20 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More