• Resolved John

    (@dsl225)


    Hello,

    I understand that the upload filed stores those submitted files in the media library and they are kept for the period defined in submission settings.

    Would it be possible to include those files as attachments of the email instead?

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @dsl225

    I hope you’re well today!

    It’s not exactly possible to use them as only attachments (without storing them at all, even for short) but you can do this:

    1. edit your “upload” field and in “Settings” set “Show files in media library” option to “Disable” – files won’t be added to media library

    View post on imgur.com

    2. in e-mail notification serttings select “Uplaoded files” instead of “none” for “attachments” option – file(s) will be attached to e-mail

    View post on imgur.com

    3. in form “Settings” (form, not Forminator) set “Submission Files” option to “Delete” – to make sure that files are deleted when submission is deleted

    4. and finally, in Forminator “Settings -> Submissions” set as short submission retention as possible.

    This isn’t an ideal solution, I understand, but would “minimize” file storage as much as possible.

    Another option could be to set the form the same way but also use this additional code to change the path (folder) where Forminator uploads the files to

    https://gist.github.com/wpmudev-sls/07079f66859c4625f00ef8a1707f068c

    and then set some server cron job to regularly empty that folder (e.g. every hour or so). This way you could actually clean-up files without removing other submission data.

    Best regards,
    Adam

    Thread Starter John

    (@dsl225)

    Many thanks Adam, that’s quite interesting as I discover plenty of options I was not aware of!

    In fact, I only need the option at point 2 and it seems I completely missed this one when setting up the form.

    The other points were already set up correctly.

    The last option for changing the path is also interesting and might be useful in other occasions.

    Where exactly do I need to enter the new path – and how exactly?
    Is it at line 46?

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @dsl225

    Yes, it is on line 46.

    I see the ticket is marked as resolved, were you able to get it working?

    Best Regards
    Patrick Freitas

    Thread Starter John

    (@dsl225)

    Thanks Patrick, the attachment option works fine indeed.

    But would be interested to know how to edit this line 46:
    $new_path = '/' . $this->new_dir_id . '/' . date( 'Y' ) . '/' . date( 'm' );

    if wanting to change the storage path.
    Or does it simply set this to root of /wp-content/ and I’m not supposed to change that path?

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @dsl225

    It should point to wp-content already so if you change it for example:

    $new_path = '/forminator-custom-folder';

    you will see the uploads on wp-content > forminator-custom-folder

    Best Regards
    Patrick Freitas

    Thread Starter John

    (@dsl225)

    Great, many thanks for this.

    But there are 3 instances of ‘/’ in this line, should I edit all 3 of them?

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @dsl225,

    There is a slight correction from what we have said above, the folder will get created under the following directory path:
    /wp-content/uploads/

    But there are 3 instances of ‘/’ in this line, should I edit all 3 of them?

    The rest of the ‘/’ used is to structure the path. You can either change the line from:
    $new_path = '/' . $this->new_dir_id . '/' . date( 'Y' ) . '/' . date( 'm' );

    To:

    $new_path = '/forminator-custom-folder';
    
    

    The above action will create a folder called “forminator-custom-folder” under /wp-content/uploads directory where the images will be saved.

    Or you can change the line 46 to:
    $new_path = '/forminator-custom-folder' . '/' . date( 'Y' ) . '/' . date( 'm' );

    And it’ll save the images by structuring the folder based on month and year, ie for example:
    /wp-content/uploads/forminator-custom-folder/2021/07/

    I hope it’s clear now. Have a nice day ahead.

    Best Regards,
    Nithin

    Thread Starter John

    (@dsl225)

    Got it, very clear!

    Many thanks to all of you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘File uploads as attachments?’ is closed to new replies.