• Resolved dan382

    (@dan382)


    Hi,

    When submitting a file I’ve noted that that files get saved to a dynamic directory:

    E.g.
    /wp-content/uploads/wpcf7-submissions/10934
    /wp-content/uploads/wpcf7-submissions/10932

    …so each submission has a unique folder.

    Is there any way to standardise the folder, so they all go into the same location?

    E.g. /wp-content/uploads/wpcf7-submissions/

    I’ve noticed a similar question was asked before and WordPress filters were mentioned:
    https://www.ads-software.com/support/topic/exposed-attachment-files/

    Would you be able to provide some example code I could implement on my custom functions.php file?

    Many thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author jasongreen

    (@jasongreen)

    Hi dan382

    I use subfolders to separate submission files for cleanliness and avoid issues with duplicate filenames.

    You can override the parent folder where the files are saved with a filter but you can’t remove the subfolders. The code to change the files location is:

    function custom_wpcf7s_dir(){
        # full path C:\path\to\wordpress\wp-content\uploads
        return $custom_dir;
    }
    add_filter('wpcf7s_dir','custom_wpcf7s_dir');
    
    function custom_wpcf7s_url(){
        # full url https://example.com/wp-content/uploads
        return $custom_dir;
    }
    add_filter('wpcf7s_url','custom_wpcf7s_url');

    Any problems let me know.

    Thread Starter dan382

    (@dan382)

    I’ve edited the core files, thanks for the heads up about the duplicated filenames. I’m just going to warn folk to upload in a certain way to avoid this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change uploaded file location’ is closed to new replies.