fileUpload - Error - Invalid file size

UI Components for JSF
Post Reply
linen
Posts: 66
Joined: 22 Jun 2011, 19:01

02 Apr 2012, 22:19

On a positive note - I'm really impressed with the elegance of the advanced fileUpload feature. I'm confident I'll get this resolved and excited about using it.

Eclipse Helios Java EE
Mac OS X 10.5.8
Java 6
JSF 2.1.7
PrimeFaces 3.2
Tomcat 7
Firefox 10.0

Using the fileUpload feature of PrimeFaces

<p:fileUpload id="imgUpl"
mode="advanced"
update="fileNameLabel"
fileUploadListener="#{imageBean.defaultUploadListener}"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
sizeLimit="1000"
label="Select an Image File" />

I notice that including a sizeLimit causes an error message to appear.

In this case, attempting to select a file of actual size 532KB causes an error message that indicates that the file is 543KB. "Invalid file size" appears as a message in red in the file information label area. But the size limit is set for 1 MB so it isn't clear why the error message appears at all.

If I eliminate the sizeLimit attribute, I do not see any error messages and the upload is successful.

Any thoughts? Many thanks...
Java 6 -- JSF Mojarra 2.2.1 -- PrimeFaces 4.0 -- Tomcat 7.0.34
Eclipse Juno Java EE -- Mac OS X 10.8.5 -- Safari 6.1.2 -- Chrome 35.0.1916

User avatar
T.dot
Expert Member
Posts: 620
Joined: 01 Feb 2012, 15:39
Location: Vienna/Austria

03 Apr 2012, 12:31

AFAIK sizeLimit is in Bytes, non in kB.

linen
Posts: 66
Joined: 22 Jun 2011, 19:01

03 Apr 2012, 14:56

Thanks! That's exactly it. ( and if I had looked at the users guide more carefully I should have seen that )
Yes changing the sizeLimit value to 1000000 works.
Java 6 -- JSF Mojarra 2.2.1 -- PrimeFaces 4.0 -- Tomcat 7.0.34
Eclipse Juno Java EE -- Mac OS X 10.8.5 -- Safari 6.1.2 -- Chrome 35.0.1916

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

03 Apr 2012, 20:56

If you are using a Windows client Explorer doesn't show you the exact file size either, you need to check the file Properties sheet to see the correct figure.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

User avatar
T.dot
Expert Member
Posts: 620
Joined: 01 Feb 2012, 15:39
Location: Vienna/Austria

04 Apr 2012, 07:22

And how should that help if you're of by a factor of 1024?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 39 guests