Send default file if no file selected

In the support forums the question was asked if it was possible to attach a default image to an email if a form user didn’t upload a file.

The form below shows one approach you can use to achieve this.

Note: for security and privacy reasons, uploaded files are not actually saved on this server. So your uploaded image will not appear in the e-mail preview. If you use the code on your own website though, it should work fine.

Form

    file* f1

    this file will be sent:

    Form Code

    [radio select-file use_label_element "default file" "uploaded file"]
    [group f1-group]
      file* f1 [file* f1]
    [/group]
    [group default-group]
      this file will be sent: <img width="50" src="https://conditional-fields-cf7.bdwm.be/wp-content/uploads/2019/04/icon-256x256.png">
    [/group]
    [submit]

    Email Body

    Here's your file:
    <img src="[f1-group][f1][/f1-group][default-group]https://conditional-fields-cf7.bdwm.be/wp-content/uploads/2019/04/icon-256x256.png[/default-group]">

    Conditional Fields (Text)

    show [f1-group] if [select-file] equals "uploaded file"
    show [default-group] if [select-file] equals "default file"

    Attachments

    [f1-group][f1][/f1-group][default-group]uploads/2019/04/icon-256x256.png[/default-group]

    Edit this form in the form tester