Description
The gform_file_upload_tmp_dir
filter allows developers to change the temporary directory used for file uploads.
Usage
Applies to all forms:
add_filter( 'gform_file_upload_tmp_dir', 'your_function_name', 10, 2 );
To target a specific form append the form id to the hook name. (format: gform_file_upload_tmp_dir_FORMID)
add_filter( 'gform_file_upload_tmp_dir_123', 'your_function_name', 10, 2 );
Parameters
- $tmp_upload_locations array
An array containing the path and url of the temporary upload directory. - $form_id int
The ID of the form.
Examples
Change the temporary file upload directory
add_filter( 'gform_file_upload_tmp_dir', function ( $tmp_upload_locations, $form_id ) {
return array(
'path' => '/Users/morgan/Local/gravity-forms/app/public/wp-content/uploads/gravity_forms/' . $form_id . '/tmp/',
'url' => 'https://gravity-forms.local/wp-content/uploads/gravity_forms/' . $form_id . '/tmp/'
);
}, 10, 2 );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This filter is located in /form_display.php
Since
The filter was added in Gravity Forms 2.9.3