[TYPO3-mvc] Frontend upload of multiple files using upload_example
Søren Andersen
hacksaw at zpeed.dk
Tue Sep 1 00:56:06 CEST 2015
I have tried creating the possibility to upload images to my newly created frontend plugin by following this example: https://github.com/helhum/upload_example
It should be possible to upload several images, which is why I have tried following the example of "image_collection", but it seems that even the image_collection property is treated like a single image, by referring specifically to image_collection.0 (the first image) different places in the code.
Like here: https://github.com/helhum/upload_example/blob/master/Classes/Controller/ExampleController.php#L165
And here: https://github.com/helhum/upload_example/blob/master/Resources/Private/Partials/Example/FormFields.html#L18
I have tried modifying the code to allow upload of multiple images, but extbase is not my main area of competence, and it is giving me a headache.
The first image, attached when the entry is created works fine. But the viewhelper is not suited to add additional images. Instead it discards the one already added. So I modified the viewhelper by commenting out parent::render(); Instead I wrote this in the template (i use images instead of imageCollection):
<f:for each="{inquiry.images}" as="image" iteration="iterator">
<sa:form.upload property="images.{iterator.index}" >
<f:if condition="{resource}">
<f:image image="{resource}" alt="" width="50" maxWidth="50" style="width: 100px; height:100px;"/>
</f:if>
</sa:form.upload>
</f:for>
<f:form.upload property="images.{inquiry.images -> f:count()}" />
But when I submit this form, the propertymapper says something about allowProperties. When I activate allowProperties it simply overwrites the current image, instead of adding a new one.
I'm not sure where the fault is, could someone help me in the right direction?
The next step for me is to upload the files via Ajax, am I in for some additional trouble using the approach of upload_example, or should this just be a minor detail?
More information about the TYPO3-project-typo3v4mvc
mailing list