Upload files to different folders

I have a form that has three different file upload fields, is it possible to have these files sent to different folders.

For example, field A uploads the file in folder A, field B uploads the file in field B, and so on…

I am aware of the global ‘gform_upload_path’, but this would be for all uploads, I need something that can be associated on a ‘per field’ basis.

Hi Simon. That filter is currently global per form; you would not be able to target specific upload fields. The $form and $entry are not available to the filter, so you would not be able to target by field.

If you think a filter for this would make a good addition to Gravity Forms, I recommend adding a note to our product roadmap. Click the blue plus in the lower left on this page to add a note for our product team:

Thank you.​​

This snippet is based on an action from Gravity Flow PDF Generator - showing how to copy the created file to a new location/filename. Your use case would likely be similar in code but leveraging the existing gform_after_submission action.

add_action( 'gravityflowpdf_generated', 'sh_gravityflowpdf_generated', 10, 3 );
function sh_gravityflowpdf_generated( $file_name, $entry_id, $form_id ) {
    $copied_file_name = 'my-file-abcd.pdf';
    $file_path = gravity_flow_pdf()->get_destination_folder();
    $source_file_path = gravity_flow_pdf()->get_file_path( $entry_id, $form_id );
    $target_file_path = $file_path . $copied_file_name;
    copy( $source_file_path, $target_file_path );
}

Regards,
Jamie

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.