This content has been marked as final.
Show 9 replies
-
1. Re: Do file upload component support jpeg and png only?
shakenbrain Jun 14, 2007 10:01 AM (in response to nhpvti)You can upload any kind of file with the file upload component. The seamspace example, however, accepts only certain types of image files. I believe it looks at the content-type of the uploaded file and rejects it when not one of the accepted types.
-
2. Re: Do file upload component support jpeg and png only?
nhpvti Jun 14, 2007 12:34 PM (in response to nhpvti)"shakenbrain" wrote:
You can upload any kind of file with the file upload component.
Yes, I can upload any content and I can see binary data of the gif image in the database with contentType field set to image/gif
But the problem is that web browsers (e.g. IE7, Firefox 2.x, Opera 9.x) don't show uploaded gif images."shakenbrain" wrote:
The seamspace example, however, accepts only certain types of image files. I believe it looks at the content-type of the uploaded file and rejects it when not one of the accepted types.<s:fileUpload id="picture" data="#{register.picture}" accept="image/gif" contentType="#{register.pictureContentType}" />
But if you mean accept attribute, it was intended for file filtering by web browsers and is ignored.
http://htmlhelp.com/reference/html40/forms/input.htmlThe file input type creates a field through which users can upload files from their local computer or network. The VALUE attribute specifies the name of the initial file, but it is typically ignored by browsers as a security precaution. The ACCEPT attribute gives a comma-separated list of media types accepted, allowing the browser to filter out inappropriate files. Current browsers generally ignore the ACCEPT attribute.
-
3. Re: Do file upload component support jpeg and png only?
shakenbrain Jun 14, 2007 12:45 PM (in response to nhpvti)I guess I'm not following you. Where is this uploaded image supposed to be shown? How are you storing it?
-
4. Re: Do file upload component support jpeg and png only?
nhpvti Jun 14, 2007 3:03 PM (in response to nhpvti)"shakenbrain" wrote:
I guess I'm not following you. Where is this uploaded image supposed to be shown? How are you storing it?
seamspace example, JBoss AS 4.0.5 GA, Seam 1.2.1 GA
Images are stored in the database and shown on the start page or in the user's profile.
It works for JPEG and PNG (with a workaround for IE7 mentioned earlier in this thread), but not for GIF. -
5. Re: Do file upload component support jpeg and png only?
pmuir Jun 14, 2007 4:17 PM (in response to nhpvti)Yes, seamspace doesn't support gifs. But, as shakenbrain says, this is not because s:fileUpload can't upload gifs, but just due to the design of the example (in fact its because Java2D doesn't support writing to a gif, probably because of licensing issues).
-
6. Re: Do file upload component support jpeg and png only?
shakenbrain Jun 14, 2007 4:17 PM (in response to nhpvti)From ContentServlet.java
String formatName = ""; if ("image/png".equals(contentType)) formatName = "png"; else if ("image/jpeg".equals(contentType)) formatName = "jpeg"; ImageIO.write(bImg, formatName, response.getOutputStream());
You'd have to update this to allow for "gif" format types, but that assumes that ImageIO supports writing GIFS. Based on "http://www.gif4j.com/java-gif4j-pro-gif-image-encode-save.htm" you'll need an extra library. -
7. Re: Do file upload component support jpeg and png only?
pmuir Jun 14, 2007 4:21 PM (in response to nhpvti)As png is a superior format to gif, I can't see any problem here.
-
8. Re: Do file upload component support jpeg and png only?
shakenbrain Jun 14, 2007 4:31 PM (in response to nhpvti)+1
-
9. Re: Do file upload component support jpeg and png only?
nhpvti Jun 14, 2007 5:22 PM (in response to nhpvti)"petemuir" wrote:
in fact its because Java2D doesn't support writing to a gif, probably because of licensing issues
It was my first suspicion...
Good news is that it is nevertheless possible and even animated:"shakenbrain" wrote:
You'd have to update this to allow for "gif" format types, but that assumes that ImageIO supports writing GIFS. Based on "http://www.gif4j.com/java-gif4j-pro-gif-image-encode-save.htm" you'll need an extra library."petemuir" wrote:
png is a superior format to gif
The same said our web design pro. But he said also that older web browsers may have trouble with PNG format. Mail clients consuming HTML emails is another case. I'll ask him to post a question in according forum(s)
Thank you both for your prompt and professional assistance
:-)
More critical is requirement to have animated images.
PNG does not support this.
Hopefully one of animation extensions (MNG or APNG or ANG or ... ) somtime will be widely adopted
http://www.xs4all.nl/~collin/png-eng.html
* A new controversy has arissen: Unisys now wants to charge every website that uses GIFs that were made with suspect software (i.e. software that has no Unisys license for LZW compression) 5000 US Dollar.
* The PNG group has started developing an animation format to help replace animated GIFs. This format is called MNG.
http://en.wikipedia.org/wiki/PNGPNG gained some additional popularity in August 1999, after Unisys terminated its royalty-free patent licenses to developers of free software and non-commercial software.