Toggle menu

File Upload Helpers

The following helpers can be used to display images and links to files that have been uploaded during a form submission.

The following helpers can be used in server-side templates. They will generally be used to display files uploaded on previous pages of your form.

DOCFIELD

{{DOCFIELD fields=(toArray "FILEONE" "FILETWO") ttl=2 title="The title" text="Supplied text"}}

This helper outputs links to files. If no parameters are supplied then links to every previously uploaded file in the form are output. Where the helper is asked to output more than one file, each file will be wrapped in a table row.

IMAGEFIELD

{{IMAGEFIELD fields="FILEUPLOADFIELD" class="testClass" title="The title" text="Supplied text"}}

This helper renders images. If no parameters are supplied then full size versions of every previously uploaded image in the form are output. Images are defined as files with the extensions "jpg", "bmp", "jpeg", "gif", and "png" all other file types are ignored. Where the helper is asked to output more than one file, each file will be wrapped in a table row.

UPLOADFIELD

{{UPLOADFIELD fields="FILEUPLOADFIELD" ttl=2 class="testClass" title="The title" text="Supplied text"}}

This helper combines the previous two. It will render images if the file is recognised as an image, a download link if it is not.

Parameters

The following are common to all three of the upload field helpers. They are all optional.

NameTypeDescription
fieldsString or subexpressionThe name of the field to render, eg {{IMAGEFIELD fields="FILEONE"}}

To output more than one field, use the toArray subexpression, eg {{IMAGEFIELD fields=(toArray "FILEONE" "FILETWO")}}
ttlInteger (minutes)Default 10

Files rendered from the filestore to the site use secure file references. This is the time in minutes that the reference will be valid for. Note that this is not the lifetime of the file, but the lifetime of the link to the file generated by the site framework
classStringA CSS class that will be appended to the existing class attribute of each figure or anchor as it is output
titleStringIf omitted the field label is used
textStringIf omitted the file name is used
pageInstanceStringThe index (zero-based) of the page instance the file upload field is on

Templates

Figure

<figure class="icmformdataimage{{class}}">
    <img src="{{url}}" alt="{{title}}" />
    <figcaption>{{text}}</figcaption>
</figure>

Anchor

<a href="{{url}}" target="_blank" title="{{title}}" class="icmformdatalink{{class}}">{{text}}</a>

Row

<tr>
    <td class="icmformdatalabel">{{label}}</td>
    <td class="icmformdatavalue">{{element}}</td>
</tr>

Example

Handlebars Template

FILETWO is a file upload field on a previous page of the form.

{{UPLOADFIELD fields="FILETWO" ttl=2 class="testClass" title="The title" text="Supplied text"}}

Output

<figure class="icmformdataimage testClass">
    <img src="secure-file-reference" alt="The title">
    <figcaption>Supplied text</figcaption>
</figure>

Use in Emails and PDFs

When you are writing templates for emails and PDFs generated by the email action field, the following apply:

  1. In email body content, images and documents only display the file name
  2. In PDFs, images are embedded, other files only display the file name
  3. To include uploaded files with an email, select "Include uploaded files" in the email action field so they are added as attachments to the email

These helpers are not available to the emails or PDFs generated by the workflow mail activity.

Last modified on February 14, 2024

Share this page

Facebook icon Twitter icon email icon

Print

print icon