TYPO3 upload multiple files in a frontend form

2019-07-15 07:12发布

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

2条回答
混吃等死
2楼-- · 2019-07-15 07:50

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'}"/>
查看更多
Fickle 薄情
3楼-- · 2019-07-15 07:58

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}"/>
查看更多
登录 后发表回答