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.

Was this article helpful?
YesNo

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.

4 thoughts on “Elementor: Change Form File Upload Directory”

  1. Hi Wil!
    Thanks for sharing this. Was looking all over the place to get this information.
    Would you be so kind to share how this code would look like if you would just “normally” upload the files to the wp Media Library?
    Thanks and all the best!
    Florian

    1. Hi Florian

      You’re welcome.

      Without the code and by default, Elementor stores all uploaded form files to the “/wp-content/uploads/elementor/forms” folder.

        1. Hey Florian

          If you want the form uploads to go to the current media folder you would replace line 16
          $path = $wp_upload_dir[‘basedir’] . ‘/’ . $folder;

          with
          $path = $wp_upload_dir[‘path’] ;

          This will save to the current media folder which is usually /wp-content/uploads/YEAR/MONTH

          Hope that helps you!

          Wil.

Leave a Comment

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