Title: Can&#039;t attach file dynamically
Last modified: August 31, 2016

---

# Can't attach file dynamically

 *  [seforoth](https://wordpress.org/support/users/seforoth/)
 * (@seforoth)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cant-attach-file-dynamically/)
 * Hi guys,
 * I’ve been trying to attach files dynamically without any success. Here’s what
   I’ve tried:
 *     ```
       add_action('wpcf7_before_send_mail','send_pdf');
       function send_pdf( $cf7 ) {
               $submission = WPCF7_Submission::get_instance();
               $submission->add_uploaded_file('pdf', '../path/to/uploads/test.pdf');
       }
       ```
   
 * I’ve also tried:
 *     ```
       add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components1', 10, 2 );
       function mycustom_wpcf7_mail_components1( $components, $form ) {
               $components['attachments'] = array("../path/to/uploads/test.pdf");
               return $components;
       }
       ```
   
 * Any ideas? Thanks!
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cant-attach-file-dynamically/#post-7319483)
 * See [File Uploading and Attachment](http://contactform7.com/file-uploading-and-attachment/)–
   [Local file attachment](http://contactform7.com/file-uploading-and-attachment/#local-file-attachment)

Viewing 1 replies (of 1 total)

The topic ‘Can't attach file dynamically’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [file upload](https://wordpress.org/support/topic-tag/file-upload/)
 * [upload](https://wordpress.org/support/topic-tag/upload/)

 * 1 reply
 * 2 participants
 * Last reply from: [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/cant-attach-file-dynamically/#post-7319483)
 * Status: not resolved