banner



How To Ad A File Upload Option In Ninja Form Builder

The File Uploads add-on needs to exist installed and activated to see the features mentioned in this this documentation.

  1. Adding and configuring a File Upload option for your users
  2. Attaching an uploaded file to an email
  3. Saving uploaded files to Dropbox, Google Drive, or Amazon S3
  4. File Uploads General Settings
  5. Advanced functionality

Adding a File Upload option to your form

A File Uploads field tin can be added to the form by clicking on the Add together Field Button on the bottom correct, then choosing the File Upload field from the list.

add new field button choose-the-file-upload-field

Configuring your File Upload field

Click on the File Upload field to open its settings window.
d
File Upload Configuration

General Settings

Label

The name of the field as displayed to your users.

Required Field

If enabled, this field must exist completed before the course can be submitted.

Salvage to Server

Enabled by default, this option will relieve an uploaded file to your server when the form is submitted.

Rename Uploaded File

If yous want the file to retain the name your user gave it, leave this blank. If you adopt your ain naming convention, you tin enter information technology hither using the merge tag button.

There is a {file:extension} merge tag, just that doesn't have to be added to the end of the setting every bit it volition be added automatically.
The {file:name} and {file:extension} merge tags are only used the field settings and can't be used in deportment or other places. Yous can also create directories using / in the name.

The quondam style "shortcodes" are still supported for renaming and can exist mixed with merge tags. These shortcodes tin can exist found in the expandable section immediately beneath:

Renaming Conventions

%filename% – The file's original filename, with any special characters removed.
%formtitle% – The title of the current form, with whatsoever special characters removed.
%username% – The WordPress username for the user, if they are logged in.
%userid% – The WordPress ID (int) for the user, if they are logged in.
%displayname% – The WordPress displayname for the user, if they are logged in.
%lastname% – The WordPress lastname for the user, if they are logged in.
%firstname% – The WordPress firstname for the user, if they are logged in.
%date% – Today'due south date in yyyy-mm-dd format.
%month% – Today's month in mm format.
%day% – Today'southward solar day in dd format.
%twelvemonth% – Today'due south yr in yyyy format.

Save to Media Library

If this setting is enabled, the File Upload will be saved to the server'south Media Library.
You can retrieve data about the attachment created in the media library using the following merge tags:
{field:my_field_key:attachment_id} – the ID of the attachment
{field:my_field_key:attachment_url} – the URL of the attachment
{field:my_field_key:attachment_embed} – an HTML image of the attachment

Restrictions Settings

Restriction Settings

File Limit

Use this option to conform 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 tin be uploaded here. This setting defaults to MB

Immune File Types

This setting creates a whitelist of the types of files that tin can be uploaded by file extension (i.due east. .pdf, .jpg, .png, .xls, etc). With information entered into this setting, users will be able to upload files of that type just.

Display Settings

Display Settings

Description

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 push when viewing the course will read "Select Files". That can exist changed to whatever y'all like hither.

Evidence Advanced Features

To see these features, you will need to enable Developer Way in Ninja Forms' settings.

Display Settings

Custom Grade Names

  • Container: Text entered hither applies a custom HTML course to this field's wrapper
  • Element: Text entered here applies a custom HTML course to this field'southward chemical element

Help Text

Entering text here will display an informational icon next to the field label. When a user hovers over it, a small window will appear containing this text.

Advanced Settings

Label Position

Changes the orientation of the field characterization relative to the field element (higher up, below, left, right, hidden)

Administration Settings

Field Key

A unique programmatic cardinal that can be used to place and target your field for custom development. Ane is generated for each field automatically, and this is what yous see pre-populated in the setting. It can be changed, though doing so will not update it in anything you've already written.


[Leap to peak]

Attaching an uploaded file to an electronic mail

This tin be accomplished in two ways, the first method via merge tag, which will and so create a link to the file(due south) uploaded in the received email.

Sending a download link with the email

  1. From the Emails and Deportment tab, edit the email activity by clicking on the action'south gear symbol. From here, click the merge tag button located in the E-mail Message line, shown beneath. Merge tag button two. Add in the File Uploads merge tag to the Email Message trunk by just clicking on it. Should your list testify many merge tags, and you accept trouble locating the right tag, take reward 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.

  1. From the Emails and Actions tab, edit the email activeness past clicking on the action's gear symbol.
  2. From the pull out drawer, scroll downward to the Avant-garde tab and click to drop down.
  3. So activate (click) the Attach File Uploads toggle.

Attach File Uploads toggle


[Jump to acme]

Saving uploaded files to Dropbox, Google Drive, 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

Connecting Ninja Forms to Dropbox

To connect Ninja Forms to Dropbox, get to Ninja Forms > File Uploads > External Settings tab and click on the Connect button

Connect to Dropbox settings

Dropbox will create a default directory of Apps/NinjaFormsUploads within your Dropbox account. While this cannot be inverse, you can use the File Path setting here to define a custom directory inside that file path for this upload field.

Connecting Ninja Forms to Amazon S3

Amazon S3 Settings
  1. Open the IAM panel inside your Amazon S3 account
  2. In the navigation pane, choose Users. And so choose your IAM user proper name.
  3. Choose the Security Credentials tab and and then cull Create Access Cardinal.
  4. To recollect your Admission Primal and Hugger-mugger Central, choose Show User Security Credentials.
  5. Choose Download Credentials, and store the keys in a secure location.
  6. Become to Ninja Forms > File Uploads > External Settings tab and enter your Admission Key ID and Clandestine Access Key
  7. Alternatively you tin can ascertain your Access Key ID and Secret Admission Fundamental as constants in wp-config.php:
    define( 'NF_FU_AMAZON_S3_ACCESS_KEY', 'xxxxxxxxxxxxxx' );  define( 'NF_FU_AMAZON_S3_SECRET_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' );
  8. If your saucepan is ready as private you will need to add together this code snippet to an mu-plugin file, eg. wp-content/mu-plugins/ninja-forms.php (the mu-plugin directory might need to be created if it doesn't exist):
    <?php   add_filter( 'ninja_forms_uploads_s3_acl', function () {  return NF_FU_External_Services_S3_Service::ACL_PRIVATE;  } );

Connecting Ninja Forms to Google Drive

To connect Ninja Forms to Google Bulldoze, get to Ninja Forms > File Uploads > External Settings tab and click on the Connect push button in the 'Google Drive Settings' box.

Connect to Google Drive button

Name the binder y'all want your file uploads to be stored in using the File Path setting. Whatever you type hither will be the name of the folder in Drive. If you exit this setting bare, files will go directly to your general My Drive area and will non exist placed in a folder.

Share with Google Drive
You tin right-click the folder where the files are beingness uploaded and click "Share with Google Drive" Then click the advanced settings in the bottom-correct and change access to anyone that has the URL.

2. Setup your form to send uploaded files to an external service

Now that you have your plugin configured to ship to either Dropbox or Amazon S3 (step 1), you demand to add and configure an External File Upload activeness on the form itself. Open your course and navigate to the Emails & Deportment tab, then click the blue circle/+ in the lesser right corner to add a new action.

add new external file upload

Under the External File Upload Action, yous can choose the service you lot would similar the files from your grade to relieve to.
choose-external-service


[Jump to elevation]

File Uploads Full general Settings

Admission these settings in your WordPress dashboard under Ninja Forms > File Uploads.

Browser Uploads

the browser uploads tab

This tab allows you to view or delete all uploaded files that take been saved to your server. You can sort past form or by engagement.

Upload Settings

the upload settings tab

  • Max File Size (in MB) – The Max File Upload size immune 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 lot migrate from another server and the File Uploads path is pointing to the older server location, you lot can conciliate and so reactivate your File Uploads and Ninja Forms plugins to reset the file path.

Avant-garde Functionality

Please note that modifying your add-on with custom code is outside the scope of back up that we are able to provide. However, this section provides solutions to highly specific utilise cases of File Uploads that may come in handy if you find yourself needing them!

Sending a directly link to the public URL of a file uploaded to External Services

To enable a straight link to the public URL for the uploaded file on Dropbox, Google Drive, or Amazon S3, turn on 'Utilize Public URL' setting in Ninja Forms > File Uploads > External Settings


Allowing file types in File Uploads that are not normally allowed by WordPress

For security purposes, File Uploads merely allows the upload of file types that WordPress allows. Even so, this list of file types tin exist amended with the 'ninja_forms_upload_mime_types_whitelist' filter.

If Allowed File Type is Setup If Allowed File Blazon is non Setup

Add to functions.php
add_filter( 'ninja_forms_upload_mime_types_whitelist', 'my_ninja_forms_upload_mime_types_whitelist' );
function my_ninja_forms_upload_mime_types_whitelist( $types ) {
//$types['esx'] = 'application/octet-stream';
render $types;
}

add_filter( 'ninja_forms_upload_check_mime_types_whitelist', '__return_false' );

Re-create & paste both the function and the filter if you prepare up the allowed file types – File Uploads > Restrictions > Allow File Types – within the File Uploads field of your form.

Include add_filter( 'ninja_forms_upload_mime_types_whitelist', 'my_ninja_forms_upload_mime_types_whitelist' );
function my_ninja_forms_upload_mime_types_whitelist( $types ) {
return $types;
}

Note: The WordPress uploads folder is attainable by default on WordPress installations. To limit access to the WordPress Uploads folder, you may want to utilize an .htaccess file.

File Upload Add-on Tutorials!

Source: https://ninjaforms.com/docs/file-uploads/

Posted by: bolandchemb1959.blogspot.com

0 Response to "How To Ad A File Upload Option In Ninja Form Builder"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel