How to modify uploaded file URL in Gravity Forms using “gform_save_field_value” filter

I want to modify the uploaded file URL before saving to database when user submits the Gravity form.

I am trying to acheive this by using “gform_save_field_value” filter in Gravity form. But when i print fields inside the filter function i never get the file upload field ID. All other fields are accessable inside filter function except file upload input field.

 add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
 function save_field_value( $value, $lead, $field, $form ) {
    print_r($field);
 }

Related posts

1 comment

  1. The gform_upload_path filter will allow you to change the upload path of the file (and the URL).

    add_filter( 'gform_upload_path', 'change_upload_path', 10, 2 );
    function change_upload_path( $path_info, $form_id ) {
       $path_info['path'] = '/home/public_html/yourdomainfolder/new/path/';
       $path_info['url'] = 'http://yourdomainhere.com/new/path/';
       return $path_info;
    }
    

    If you need to change the actual name of the file, here is a snippet that makes it a cinch.

    http://gravitywiz.com/rename-uploaded-files-for-gravity-form/

Comments are closed.