Created
May 19, 2017 15:39
-
-
Save spivurno/11e031b6b7b8776511c6deeda3e54058 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Get Uploaded Files Prior to Submission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Wiz // Gravity Forms // Get Uploaded Files Prior to Submission | |
* | |
* @param integer $form_id The form ID that contains that field for which you are fetching the uploaded file details. | |
* @param GF_Field $field The field object for which you are fetching the uploaded file details. | |
* | |
* @return array|bool | |
*/ | |
function gw_get_uploaded_file_deets( $form_id, $field ) { | |
$input_name = sprintf( 'input_%s', $field->id ); | |
$is_save_and_continue = rgget( 'gf_token' ) != false; | |
// hack alert: force retrieval of unique ID for filenames when continuing from saved entry | |
if( $is_save_and_continue && ! isset( $_POST['gform_submit'] ) ) { | |
$is_gform_submit_set_manually = true; | |
$_POST['gform_submit'] = $form_id; | |
} | |
$uploaded_files = isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] : array(); | |
$file_info = rgar( $field, 'multipleFiles' ) ? $uploaded_files : GFFormsModel::get_temp_filename( $form_id, $input_name ); | |
if( $is_save_and_continue && ! isset( $_POST['gform_submit'] ) ) { | |
$_POST['gform_submit'] = $form_id; | |
} | |
// hack alert: force retrieval of unique ID for filenames when continuing from saved entry | |
if( isset( $is_gform_submit_set_manually ) ) { | |
unset( $_POST['gform_submit'] ); | |
} | |
return $file_info; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment