How to send multiple attachments to email
<p>I have the following simple form that is ment to send multiple files to email:</p>

<pre><code>&lt;form method="post" enctype="multipart/form-data"&gt;
            &lt;input id="upload-file" class="upload-file" type="file" name="my_file[]" multiple&gt;
            &lt;input type="submit" value="Send"&gt;
        &lt;/form&gt;
</code></pre>

<p>I am using the following php code to do the actual sending:</p>

<pre><code>if (isset($_FILES['my_file'])) {
        $to = 'my-email@maybe-gmail.com';
        $subject = 'Files moar files';
        $message = 'Message Body';
        $headers = 'Some random email header';
        $attachments = array();
                $myFile = $_FILES['my_file'];
                $fileCount = count($myFile["name"]);
                for ($i = 0; $i &lt; $fileCount; $i++) {

                   $attachments[$i] = $_FILES['my_file']['tmp_name'][$i];
                }
        wp_mail($to, $subject, $message, $headers, $attachments);
            }
</code></pre>

<p>I am using wp_mail() method, because this is in a Wordpress website(it is the same as the php mail() function).
My problem is, that I receive an email with the attachments, but the name of the file is messed up, and there is no extension, so it's hard to open it. What am I doing wrong here, and how can I fix it?</p>