Support » Plugin: Forminator Payment, Quiz and Contact Form Plugin » How to change upload directory

  • Resolved desmogiec


    I would like to change the upload directory when uploading a file from a form.
    I’d like to have something like wp-content/upload/forms/files.ext instead of wp-content/upload/year/month
    Is it possible or the upload function included is directly correlated to the main wp setting?
    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Predrag Dubajic WPMU DEV Support


    Hey Mirko,

    There’s no direct option in Forminator for this but using below mu-plugin should help you accomplish it:


    I’ve tried this before, today an update showed up and now I’m on (1.5 before).
    Now this works simply fine!
    Thank you!
    Just one more thing.
    I’d like to have a custom dir, like /eventi/xxx/yyyy/mm/file.ext
    xxx is supposed to be a text based on the form id.
    eg, form id = 10, upload directory will be /eventi/DIR_A/etc
    form id = 11, dir will be /eventi/DIR_B/

    is it possible?
    I’ve tried

       public function my_form_ad_formid_to_upload_dir( $param ) {
    if $this->new_dir_id = 3439 {
                $updir = "test_a";
            else {
                $updir = "test_b";
            $new_path = '/eventi/' . $updir . '/' . date( 'Y' ) . '/' . date( 'm' );

    Note, I’m not a php expert nor a developer, so I’m not sure if the if statement can work with that call

    At the very least Forminator needs to place all uploads into a Forminator folder under Uploads by default. Now you have all the uploads mixed in with all other media files and it’s a mess. Not only that, but when you delete a submission it doesn’t delete the upload associated with it so it soon becomes impossible to clean up old submissions mixed in with normal media such as photos.

    I believe most other form plugins use their own folder.

    Plugin Support Predrag Dubajic WPMU DEV Support


    Hey guys,

    I have passed over this to our devs to consider implementing this change in future releases 🙂

    @desmogiec, can you try replacing this line:
    $new_path = '/' . $this->new_dir_id . '/' . date( 'Y' ) . '/' . date( 'm' );
    With this:

    $dir_name = $this->new_dir_id;
            $form = Forminator_API::get_form( $this->new_dir_id );
            if ( $form instanceof Forminator_Custom_Form_Model ) {
                $dir_name = $form->raw->post_name;
            $new_path = '/' . $dir_name . '/' . date( 'Y' ) . '/' . date( 'm' );

    And see if that does the trick for you.


    Woah, that works greatly!
    Can I ask you if it is possible to customize it?
    I mean, in the form there’s a text box. Is it possible to create a directory based on the content of that text box?
    Having a structure like:
    /events/text a/ files
    /text b/ files
    where text a is written everytime by who is submitting the form. Could it be done?

    Thanks in advance!
    And.. awesome work/support|

    • This reply was modified 1 year, 3 months ago by desmogiec.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to change upload directory’ is closed to new replies.