-->

TYPO3 upload multiple files in a frontend form

2019-07-15 07:22发布

问题:

I'm using the https://github.com/helhum/upload_example to create a form that allow file upload in frontend. It works fine with single file but I would need to upload multiple files.

So here is my form field :

<mr:form.upload property="files" id="publication-files-{contentUid}" class="file"
                        data="{loading-text: '{f:translate(key: \'uploading\', extensionName: extKey)}', max-file-size: maxFileSize}"
                        additionalAttributes="{autocomplete: 'off', accept: settings.allowedFiles, multiple: 'multiple'}"/>

Note that I've added the addition attribute "multiple".

When I send the form I always get 1 file in the convertFrom method of the UploadedFileReferenceConverter class, even if I've chosen 3 or 4...

Does someone already experimented that? If yes, please help :)

Thanks,

Jérémie

回答1:

I found the problem. I had to use the native "multiple" argument of form.upload ViewHelper like that :

<mr:form.upload property="files" multiple="multiple" id="publication-files-{contentUid}" class="file"
                        data="{loading-text: '{f:translate(key: \'uploading\', extensionName: extKey)}', max-file-size: maxFileSize}"
                        additionalAttributes="{autocomplete: 'off', accept: settings.allowedFiles}"/>


回答2:

Remove the .0 from property. This says: Use the domain model attribute "files" and declare the first array object.

so you must have:

<mr:form.upload property="files" id="publication-files-{contentUid}" class="file"
                        data="{loading-text: '{f:translate(key: \'uploading\', extensionName: extKey)}', max-file-size: maxFileSize}"
                        additionalAttributes="{autocomplete: 'off', accept: settings.allowedFiles, multiple: 'multiple'}"/>