mzur / kirby-uniform

A versatile Kirby plugin to handle web form actions.
https://kirby-uniform.readthedocs.io
MIT License
252 stars 40 forks source link

How can i add uploaded files as attachments to the email #169

Closed christianschley closed 5 years ago

christianschley commented 5 years ago

i tried something like

'attachments' => [ 'assets/images/favicon.png', $form->data('filefield'), ],

but it didnt work. There is this error:

bildschirmfoto 2019-01-17 um 18 37 34

So how can i add uploaded files as attachments to the email?

christianschley commented 5 years ago

The added favicon to the mail is sent as attachment, but not the uploaded file.

mzur commented 5 years ago

What is tofiles() supposed to do? data('filefield') returns the item from the $_FILES array so it might work like this:

'attachments' => [$form->data('filefield')['tmp_name']],
christianschley commented 5 years ago

Ah okay, it works this way, but the attached files get the tmp_name as filename and these are e.g.: "phpmWbJ1V" without the extension .jpg or .pdf.

Not very easy to explain this to customers :)

'name' instead of 'tmp_name' doesn't work :/

mzur commented 5 years ago

You could:

mzur commented 5 years ago

Please reopen if this is still relevant.