Neos.Form.Builder Attachments


has anyone experience with the Neos.Form.Builder? Because I want to send more then 1 Attachment with 1 file upload.
I tried it with multiple="multiple" in the Neos.Form FileUpload.html, but it only send the last Attachment.

What do I have to observe?

Thank you

Hi “Ho Bu”,

I’m afraid that won’t be as simple as that. The example FileUpload Form Element is built to convert a single persistent resource.
You probably have to implement a custom Form Element class (along the lines of and invoke the conversion manually in onSubmit() and/or create a custom type converter.

Hello Ho Bu

I am trying to solve the same problem. Were you able to work this out somehow?


I created a ticket for this: – feel free to comment your ideas there

Thank you!

FYI: I just created a little package providing an example MultiFile Upload Form Element:

Hey Bastian

I had not seen this until now. This is great, I think with this I will be able to extend what I had so far. Thanks a lot!!

1 Like

We are using this in the form builder and thus also need to pass all attachments in the email finisher. For this to work, we had to extend a method in that class a bit:

protected function addAttachments(SwiftMailerMessage $mail)
        $formValues = $this->finisherContext->getFormValues();
        if ($this->parseOption('attachAllPersistentResources')) {
            foreach ($formValues as $formValue) {
                if (is_array($formValue)) {
                    foreach ($formValue as $value) {
                        if ($value instanceof PersistentResource) {
                            $this->addAttachmentToMail($mail, $value);
                } elseif ($formValue instanceof PersistentResource) {
                    $this->addAttachmentToMail($mail, $formValue);
                } elseif ($formValue instanceof Image) {
                    $resource = $formValue->getResource();
                    $this->addAttachmentToMail($mail, $resource);
        $attachmentConfigurations = $this->parseOption('attachments');
        if (is_array($attachmentConfigurations)) {
            foreach ($attachmentConfigurations as $attachmentConfiguration) {
                if (isset($attachmentConfiguration['resource'])) {
                if (!isset($attachmentConfiguration['formElement'])) {
                    throw new FinisherException('The "attachments" options need to specify a "resource" path or a "formElement" containing the resource to attach', 1503396636);
                $resource = ObjectAccess::getPropertyPath($formValues, $attachmentConfiguration['formElement']);
                if (!$resource instanceof PersistentResource) {
                $mail->attach(\Swift_Attachment::newInstance(stream_get_contents($resource->getStream()), $resource->getFilename(), $resource->getMediaType()));

    protected function addAttachmentToMail(SwiftMailerMessage $mail, PersistentResource $resource)
        $mail->attach(\Swift_Attachment::newInstance(stream_get_contents($resource->getStream()), $resource->getFilename(), $resource->getMediaType()));

We also allowed files from the image upload to get attached to the email.

Maybe this will help others too.