• Resolved antonv

    (@antonv)


    Saving to draft also saves [file* naf-pdf limit:2M filetypes:PDF] into the WordPress media uploads correctly (uploaded wp-content/uploads/2022/09 and proper data base entry in wp_post). naf-pdf is mapped to Feature Image on the Form to Post tab.

    When revisiting the form, the media uploaded is not prefilled. I do understand that as the file path is local and that there is no way of the sever to know it. Therefore, it is impossible for the server to repopulate this field on subsequent visits.

    This can now be misused insofar that a malicious operator can upload infinite many files and fill up the server storage without the site administrators being aware of it. (no notification emails possible by design)

    Could you please consider, urgently, that when saving to draft that the [file ...] field is ignored.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    When revisiting the form, the media uploaded is not prefilled.

    that’s correct, default file fields cannot be pre-filled. This is a limitation of the browser itself.

    Therefore, it is impossible for the server to repopulate this field on subsequent visits.

    it is possible with a js plugin file field (like drag and drop file upload fields)

    Could you please consider, urgently, that when saving to draft that the [file …] field is ignored.

    ignored, or saved to the same location? This way subsequent uploads would just overwrite what was saved previously.

    Thread Starter antonv

    (@antonv)

    As the user on subsequent visits has no confirmation that the uploaded file was accepted he/she is going to attach the file again, and must do so if the requirement is set by [file* ...]

    In the meantime I solved the problem by

    add_action('cf7_2_post_form_mapped_to_page', 'saved_new_post_mapped',10,3);
    function saved_new_post_mapped($post_id, $cf7_form_data, $cf7form_key){
       if ('new-article-form'==$cf7form_key) {
          if(isset($cf7_form_data['save_cf7_2_post']) && 'true'==$cf7_form_data['save_cf7_2_post']){
             $attachments = get_attached_media( '', $post_id );
             foreach ($attachments as $attachment) {
                wp_delete_attachment( $attachment->ID, 'true' );
             }
          }
       }
    }

    Here with this action the previous uploaded media is immediately deleted if the form is saved to draft.

    Again, I must praise you for well documented source code allowing me to extract the relevant code and hooks.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    In the meantime I solved the problem by

    nice one!

    Again, I must praise you for well documented source code allowing me to extract the relevant code and hooks.

    most welcome. I code these plugins with developers in mind so others can build on top of it.

    I will add a todo note for providing a better solution to this issue.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    PS: When you get a moment to write a review, thanks!

    Thread Starter antonv

    (@antonv)

    housekeeping: marking as resolved

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Media uploads saved to draft, but missing at later visit’ is closed to new replies.