Multiple files upload in Liferay 6.1

Today I have found a weird bug in Liferay’s UploadServletRequestImpl in the following method

 

The intention of the above code is to return the full name of the file(s) being uploaded. But actually the above code returns the name of the first file uploaded on the form with the name field.

But what if I have multiple files uploads on my form with the same name like this

 

If you upload two files on the above form the following code will always print name of the first file

 

Workaround

You can use uploadPortletRequest.getMultipartParameterMap() to get all the multipart parameters for a parameter name. The following code will print the name of all the files

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *