Elementor: Change Form File Upload Directory

Elementor Pro makes it super easy to let your website visitors upload a file, using their native form widget.

By default, Elementor stores the file uploads in a folder on your server at /uploads/elementor/forms/

There are no options on the widget UI to change this location.

It can easily be changed with a few lines of code.

Here’s an example.

/**
 * Change default location of Elementor's form file uploads
 *
 * @param $path
 * @return string
 */
function zpd_change_elementor_form_upload_path( $path ){

    //The folder name
    $folder = 'elementor-file-uploads';

    // Get the WordPress uploads folder
    $wp_upload_dir = wp_upload_dir();

    // This is the new path where we want to store the Form file uploads
    $path = $wp_upload_dir['basedir'] . '/' . $folder;

    /**
     * Check to see if the folder already exists, create if not.
     */
    if ( !file_exists( $path ) ) {
        mkdir( $path, 0755, true);
    }

    return $path;
}
add_filter( 'elementor_pro/forms/upload_path', 'zpd_change_elementor_form_upload_path', 10, 1 );

You can add this code to your theme’s functions.php file and the change will take place when you refresh a website page.

In this example, I am storing the files in a /uploads/elementor-file-uploads/ folder.

If you are storing sensitive data, perhaps add a .htaccess file into the folder to restrict access.

Keep In Touch

Wil

Wil is a dad, consultant, developer, conference organiser, speaker and business mentor. He co-organizes the WordPress Sydney meetup group and has been on the organising committee for WordCamp Sydney since 2014. He speaks at many special events and contributes to the WordPress open source project. His likes are chillies, craft beer and electrogravitics.

Leave a Comment

Your email address will not be published. Required fields are marked *