I need to add the ability to have multiple attachments from the input field on my Wordpress site. Currently I used jQuery code to clone the input field and assign new ID and name with increment of 1.

The problem is no matter how many attachments I upload and send, only the first one gets delivered in mailbox. I checked Wordpress codex and found wp_mail function that should do what I need, but I need tweak it for taking multiple attachments. Code below:

    $attachments = array( WP_CONTENT_DIR . '/uploads/file_to_attach.zip' );
    $headers = 'From: My Name <[email protected]>' . "\r\n";
    wp_mail( '[email protected]', 'subject', 'message', $headers, $attachments );

    jQuery('document').ready(function() {
    var cloneCount = 1;
    var cloneCount2 = 1;
    jQuery('.file-upload').on('click', function(){
       .attr({id: 'file-image'+ cloneCount++, name: 'file-image'+ cloneCount2++})

    <span class="file-upload">
       <input name="file-image" size="40" id="file-image" aria-invalid="false" type="file">

1 Answer 1


Did you try this plugin? Multifile Upload Field for Contact Form 7

  • I know it but haven't tried it yet, from what I read it zips the attachments. Might try if all other solutions fail. Thanks!
    – Radi
    Commented Nov 1, 2017 at 12:21
  • I guess I will stick with your answer for now.
    – Radi
    Commented Nov 1, 2017 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.