Upload
Statamic Forms 2 combines the Assets and Files fieldtypes into one Upload fieldtype. Its Store Files setting decides what happens to the files. Existing assets and files fields are converted automatically.
Stored uploads
With Store Files on, files are saved to an asset container. Easy Forms renders a drag-and-drop field.
handle: photos
field:
type: upload
display: Photos
store: true
container: uploads
max_files: 3
Set the files to upload on a private container
You should never use a publicly accessible container, as this would allow malicious users to upload and access files on your server.
Uploads that aren't stored
With Store Files off, files are only attached to the emails of the form and then deleted. Easy Forms renders a simpler field with minimal JavaScript.
handle: documents
field:
type: upload
display: Documents
store: false
max_files: 2
Enable attaching the files to the email
Turn on Attachments in the email connection. Ensure these emails are sent only to your own email account; otherwise, a third party could use your form to send malicious files to others.
Limits
max_filesandmin_fileslimit the number of files. Without a maximum, any number of files is accepted.- Use the
max_filesizevalidation rule to limit the size andmimesto restrict the file types.
Which one to use?
Storing the files is generally preferable, as you can manage them in Statamic's Assets section. However, this requires that the user viewing the file has access to the Statamic Control Panel.
Without storing them, files are attached directly to the email. This is a better option if you do not want to grant Control Panel access, though you risk losing files if the email fails to send.
TIP
Uploads are not supported inside groups and grids.