Mohanrao Kolisetti
Mohanrao Kolisetti

Reputation: 29

How to upload multiple files(picking mutliple files at once) using JSF1.2

How to pick multiple files at once using JSF 1.2. I am able to upload multiple files using rich faces(only one file selection at once), but can't pick multiple files at once. Prime faces provides support for multi file upload but to work with Prime Faces, JSF2.x version is required. We are stick to JSF 1.2.

In rich faces <rich:fileUpload/> tag has an attribute allowFlash, if we make this value as true it allows us to select multiple files, but after selecting multiple files its throwing an error saying

ContentTypeList does not contain a supported content type: text/*

After throwing error, even the upload button dissapears

Even I referred few other libraries like blue imp jquery multi file upload but I have zero knowledge on jquery and I don't find any example related to JSF1.x file upload. Can anybody knows the solution?.

Upvotes: 0

Views: 1675

Answers (1)

olexd
olexd

Reputation: 1420

If your application runs on a JavaEE 6 application server or on a (with JSF 2.x configured) servlet container, take a look at Primefaces file upload component. It supports multiple file selection for a modern browsers. You could set file pattern to be accepted only *.zip files from browser's file selection dialog, using:

<p:fileUpload fileUploadListener="#{bean.listenerMethod}" mode="advanced" multiple="true" allowTypes="/(\.|\/)(zip)$/" />

For a legacy JSF 1.2 environment you could use Primefaces <= 2.1 or as mentioned @VasilLukach RichFaces 3.3.3 file upload component. Both of them support only single file selection (in order to upload several files, user have to click on a file selection button several times).

See more examples and/or documentation in linked showcases above.

Regardless of the used component library, your use case mentioned in comment:

I need to select all the three zip files from browser , then extract individual zip files and upload them into server

seems to be wrong. Usually user choose one or several files to be uploaded and then they are processed after transmission by your application on the server-side (unzip, persist or whatever else).

Upvotes: 1

Related Questions