TYPO3 upload multiple files in a frontend form

做~自己de王妃 提交于 2019-12-12 21:12:49

问题


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'}"/>


来源:https://stackoverflow.com/questions/46172252/typo3-upload-multiple-files-in-a-frontend-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!