• Resolved adentone

    (@adentone)


    Hi Support,

    You have made a great plugin here and I just need a little help.

    I have this code that Gravity Forms Support gave me for being able to change the file upload directory to be dynamic – based on an email address provided within the same form.

    /*
    * This function dynamically changes the upload path of file uploads when using gravity forms, based on saving to an "email address" directory
    */
    add_filter( 'gform_upload_path', 'wdw_change_upload_path', 10, 2 );
    function wdw_change_upload_path( $path_info, $form_id ) {
        if ( $form_id == 1 ) {
            $time = current_time( 'mysql' );
            $y = substr( $time, 0, 4 );
            $m = substr( $time, 5, 2 );
            $email = $_POST['input_3'];
            $upload_dir = wp_upload_dir();
            //echo "<pre>".print_r($upload_dir, true)."</pre>";
            $path_info['path'] = $upload_dir['basedir']."/clients/$email/$y/$m/";
            $path_info['url'] = $upload_dir['baseurl']."/clients/$email/$y/$m/";
        }
        return $path_info;
    }

    I’d like to be able to use the same or very similar code to change the upload directory of your plugin. Which hook(s) or action(s) should I use? How should I use them?

    In the documentation, a few examples of each of the options would be very helpful!

    I hope this also helps others, too.

    Thank you for your time & help,
    Andy

    https://wordpress.org/plugins/gravity-forms-advanced-file-uploader/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ben.moody

    (@benmoody)

    Hi

    You can use this filter to change the upload directory to a custom sub dir in the uploads parent dir:

    add_filter( ‘prso_gform_pluploader_wp_upload_dir’, $wp_upload_dir );

    $wp_upload_dir[‘path’] is the full path to the dir within the uploads dir. You can change this to whatever you need it to be, but it must be a sub dir of uploads. The sub folder doesn’t have to exists as my plugin will create it for you.

    Thanks

    Ben

    how to change uploaded file name based on another filed value?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change file upload directory to be dynamic’ is closed to new replies.