- Adding and configuring a File Upload option for your users
- Attaching an uploaded file to an email
- Saving uploaded files to Dropbox or Amazon S3
- File Uploads General Settings
- Advanced functionality
Adding a File Upload option to your form
A File Uploads field can be added to the form by clicking on the Add Field Button on the bottom right, then choosing the File Upload field from the list.
Configuring your File Upload field
Click on the File Upload field to open its settings window.
The name of the field as displayed to your users.
If enabled, this field must be completed before the form can be submitted.
Save to Server
Enabled by default, this option will save an uploaded file to your server when the form is submitted.
Rename Uploaded File
If you want the file to retain the name your user gave it, leave this blank. If you prefer your own naming convention, enter it here. You can create directories using / in the name.
There are a number of different “shortcodes” supported for renaming, which can be found in the expandable section immediately below:
Save to Media Library
If this setting is enabled, the File Upload will be save to the server’s Media Library.
Use this option to adjust the number of files that be uploaded from this File Upload field.
Maximum File Size
Set the maximum size of the file that can be uploaded here. This setting defaults to MB. Your server also likely has a maximum file size limit, so if you set something here and users still cannot upload files of that size, contact your host to have the server file size limit increased.
Minimum File Size
Set the minimum size of the file that can be uploaded here. This setting defaults to MB
Allowed File Types
This setting creates a whitelist of the types of files that can be uploaded by file extension (i.e. .pdf, .jpg, .png, .xls, etc). With data entered into this setting, users will be able to upload files of that type only.
Any text entered here will appear between the label and the field.
Select File Button Text
By default, the text that appears on the File Uploads button when viewing the form will read “Select Files”. That can be changed to whatever you like here.
Attaching an uploaded file to an email
This can be accomplished in two ways, the first method via merge tag, which will then create a link to the file(s) uploaded in the received email.
Sending a download link with the email
- From the Emails and Actions tab, edit the email action by clicking on the action’s gear symbol. From here, click the merge tag button located in the Email Message line, shown below. 2. Add in the File Uploads merge tag to the Email Message body by simply clicking on it. Should your list show many merge tags, and you have trouble locating the correct tag, take advantage of the merge tag search bar and type File Uploads to locate the appropriate tag.
Attaching the file(s) to the email
The second method will attach the file(s) itself to the email itself.
- From the Emails and Actions tab, edit the email action by clicking on the action’s gear symbol.
- From the pull out drawer, scroll down to the Advanced tab and click to drop down.
- Then activate (click) the Attach File Uploads toggle.
Saving uploaded files to Dropbox or Amazon S3
This process requires 2 steps: 1) adjusting plugin settings and 2) adjusting form settings
1. Setup your plugin settings to send uploaded files to an external service
2. Setup your form to send uploaded files to an external service
Now that you have your plugin configured to send to either Dropbox or Amazon S3 (step 1), you need to add and configure an External File Upload action on the form itself. Open your form and navigate to the Emails & Actions tab, then click the blue circle/+ in the bottom right corner to add a new action.
File Uploads General Settings
Access these settings in your WordPress dashboard under Ninja Forms > File Uploads.
This tab allows you to view or delete all uploaded files that have been saved to your server. You can sort by form or by date.
- Max File Size (in MB) – The Max File Upload size allowed per form.
- File upload error message – The Error Message that the user receives when the Max File Size is met.
- Custom Directory – Is used to create dynamic directories.
If you migrate from another server and the File Uploads path is pointing to the older server location, you can deactivate then reactivate your File Uploads and Ninja Forms plugins to reset the file path.
Please note that modifying your add-on with custom code is outside the scope of support that we are able to provide. However, this section provides solutions to highly specific use cases of File Uploads that may come in handy if you find yourself needing them!
Sending a direct link to the public URL of a file uploaded to External Services
You can use the following code to send a direct link to the public URL for the uploaded file on Dropbox or Amazon S3
define( ‘NINJA_FORMS_UPLOADS_USE_PUBLIC_URL’, true );
Whitelisting file types that are allowed by File Uploads but not by WordPress
For security purposes, File Uploads only allows the upload of file types that WordPress allows. However, this list of file types can be amended with the ‘ninja_forms_upload_mime_types_whitelist’ filter:
Alternatively you can deactivate this type checking if you are whitelisting extensions in the field setting using this filter: