The gform_post_multifile_upload action in Gravity Forms allows further actions to be performed after multiple files have been uploaded.
Usage
Apply to all forms:
add_action('gform_post_multifile_upload', 'your_function_name', 10, 5);
Target a specific form by appending the form ID to the hook name (format: gform_post_multifile_upload_FORMID):
add_action('gform_post_multifile_upload_2', 'your_function_name', 10, 5);
Parameters
- $form (Form Object): The form object.
- $field (Field Object): The field object.
- $uploaded_filename (string): The name of the file uploaded.
- $tmp_file_name (string): The temporary name of the file while it was uploaded.
- $file_path (string): The path where the file is uploaded.
More information
See Gravity Forms Docs: gform_post_multifile_upload
Source Code: This filter is located in GFAsyncUpload::upload() in upload.php
.
Examples
Copy file to a backup folder
Create a backup copy of a file with a specific name after it’s uploaded.
add_action('gform_post_multifile_upload', 'upload_alert', 10, 5); function upload_alert($form, $field, $uploaded_filename, $tmp_file_name, $file_path) { $dirname = dirname($file_path); if ($uploaded_filename == '600x500.png') { copy($file_path, $dirname . '/backup_' . $uploaded_filename); } }