• Resolved maximbelenkii

    (@maximbelenkii)


    Hi!
    I want to get the URL of the file or files that is being sent through the form. For regular fields, I do it like this:

    add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' ); 
    function contactform7_before_send_mail( $contact_form ) {
    	$title = $contact_form->title;
    	$submission = WPCF7_Submission::get_instance();
            $posted_data = $submission->get_posted_data();
            $name = sanitize_text_field ($posted_data['name']);
    }

    Thanks!

    • This topic was modified 2 years, 5 months ago by maximbelenkii.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Glen Don Mongaya

    (@glenwpcoder)

    Hi @maximbelenkii ,

    You can access the path of the files by accessing the $posted_data[‘your-upload-name’]

    This will return something like this.

    /wpcf7-files/upload-2.jpg
    /wpcf7-files/upload-2.jpg

    And you can add the full url of your site something like “https://example.com/wp-content/uploads”

    Your-upload-name should match the upload field name in your contact form 7.

    Please let me know.

    Regards,
    Glen

    Thread Starter maximbelenkii

    (@maximbelenkii)

    It works great! Thanks!
    Additionally for myself I used:

    $uploadfile = $posted_data['your-upload-name'];
    $uploadfilevar = implode("\n\n", $uploadfile);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to intercept the URL of a field’ is closed to new replies.