Issue Details (XML | Word | Printable)

Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Neil Griffin
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.

Add file upload specific attributes to h:inputFile component tag

Created: 14/Feb/12 08:53 PM   Updated: 08/Nov/13 09:15 PM
Component/s: Components/Renderers
Affects Version/s: 2.0, 2.1
Fix Version/s: None

Time Tracking:
Not Specified

Participants: andy_bosch, muellermi and Neil Griffin

 Description  « Hide

This issue serves as a proposal for enhancing the new h:inputFile component tag with additional attributes.

The three attributes that I would like to propose are:

  • location: String indicating the directory that uploaded file should be copied to. If not specified, then the "location" specified in the Servlet 3.0 web.xml context parameter will be utilized.
  • maxFileSize: Integer representing the maximum number of bytes that the component will accept for an uploaded file. If not specified, then the "max-file-size" specified in the Servlet 3.0 web.xml context parameter will be utilized.
  • mimeTypes: Comma-delimited list of uploaded file mime types that are valid. If not specified, then all mime types are assumed to be valid.

muellermi added a comment - 26/Nov/12 08:23 PM

Hm, better to be a follower or on the cutting edge? Innovation lives from new ideas.
BTW, most file explorers, FTP uploads etc. offers options to prevent or allow overwrite or to keep both versions (rename).

Neil Griffin added a comment - 26/Nov/12 04:18 PM

I think it is the case with every implementation of file upload that I have seen, that the file would be overwritten.

muellermi added a comment - 25/Nov/12 08:03 AM - edited

What will happen if a file of same name exists in upload location?
The web developer may hook into.

I propose to add an additional attribute as hint to create a default behavior if not hooked in.


rename will append some chars to the filename (e.g. a simple count) to make it unique

andy_bosch added a comment - 24/Nov/12 08:21 PM

I like that idea. Would definitly makes sense!

Neil Griffin added a comment - 24/Nov/12 06:31 PM

In the "What's new in JSF 2.2" presentation that Ed Burns gave at JavaOne 2012, he mentioned that h:inputFile can work with a standard JSF validator. So for the "maxFileSize" and "mimeTypes" attributes, perhaps it would be better to introduce a new f:validateFile component:

<f:validateFile maxFileSize="1048576" mimeTypes="png,gif,jpg" />