Formidable Forms: Changing the File Upload Folder

The Problem:

You may want to change the folder that files will be uploaded to when using the File Upload field. This can be uploaded to somewhere on an existing folder on your server and NOT as a sub-directory of the /uploads/formidable/ folder.

To further complicate matters, you may already have a folder per client set up (a problem we came across where folders were created by the WP-Client Plugin) and need the folder name to be looked up depending on who is logged in although you could remove this addition if you don’t need it.

The Solution:

The solution is actually quite simple although it can be a bit tricky for non coders out there. Add this to a new plugin or your themes functions.php file.

add_filter( 'frm_upload_folder', 'frm_custom_upload', 10, 2 );
    function frm_custom_upload( $folder, $atts ) {
    if ( $atts['form_id'] == 92 ) { // change to your form id
    global $current_user;
    $folder = '../uploads/wpclient/_file_sharing/' . $current_user->wpc_cf_client_file_cat;
 }
    return $folder;
}

The folder file path requires ../ at the start to take you up a level from the default formidable folder and then from there you can define the folder you wish your files to be uploaded to.

We have a custom field in each user profile which contains the name of the users File Upload folder which is then looked up and added to the end of the file path using $current_user->wpc_cf_client_file_cat

So now when my client Mr Test logs in and uploads a file using this form it will be uploaded to his existing folder like this:

/public_html/wp-content/uploads/wpclient/_file_sharing/MrTest instead of the normal Formidable directory.

Still have questions?

Still have questions or not sure where to start? Use our quick contact to ask us a question.

Start Planning

If you’re ready to get started click here to complete our Project Planner.

You may also like…

FormidableTutorials
26 Mar 2019

Formidable Forms: File Upload Folder

Formidable Forms: Changing the File Upload Folder The Problem: You may want to change the folder that files will be…
FormidableTutorials
26 Mar 2019

Formidable Forms: Create an Invoicing system

Formidable Forms: Create an Invoicing system Here’s a guide on how to use Formidable Pro to create an invoicing system…
FormidableTutorials
26 Mar 2019

Share a form entry between users

Formidable Forms: Create a shared entry & view The Problem In some cases you may need to build a form…