Skip to content

FileUpload: CSV Multiple fileupload doesn't upload files, if one of them is not valid #13211

@milansie

Description

@milansie

Describe the bug

Hi,

There is a change in the fileUpload reimplementation which is (in my opinion) not correct. Until PF13, when a user used multiple fileupload and tried to upload multiple files, if one of them did not meet the criteria, the others were successfully uploaded.
Since PF14, there has been a change which prevents uploading any file in such cases.

In the previous implementation, this code was in the add method in 2-fileupload.js:

            add: function(e, data) {
...
   var validMsg = $this.validate(file);

// do some stuff on the base of validMsg

Each file was handled separately.

The current implementation is:

            add: function(e, data) {
...
                    var validationResult = PrimeFaces.validation.validate($this.jq, dataFileInput, update, true, true, true, true);
                    if (!validationResult.valid) {

This validate method is called each time any file is added, but PrimeFaces.validator['primefaces.File'] validates the entire set of files, and if any of them is not valid, it returns false.

Therefore, there are two possible bugs (improvements) that should be considered for fixing (if possible):

  • Prevent multiple validation (whilst the validation of files is fast because it only validates name and size, it validates all files n² times)
  • Restore the possibility to upload files which are correct - and report only invalid files

I haven't tested it with server-side validation, just client-side. It might work correctly with server-side validation; however, in my opinion, server-side validation for file upload is not the right approach.

Reproducer

On the PF showcase (https://www.primefaces.org/showcase/ui/file/upload/multiple.xhtml), try to upload JPG and XLS files; none of them are uploaded. The JPG file(s) should be uploaded.

Expected behavior

Files that meets validation criterias should be uploaded

PrimeFaces edition

Community

PrimeFaces version

14.0+

Theme

No response

JSF implementation

All

JSF version

all

Java version

all

Browser(s)

all

Metadata

Metadata

Assignees

Labels

🐞 defectBug...Something isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions