PDA

View Full Version : Attaching MULTIPLE files to an email, using php


Jabbamonkey
08-28-2002, 02:05 AM
I have my webform set up to allow a user upload multiple files at a time. For example, there will be four "browse" file fields where they can choose files off their computer. After they choose the files, they hit submit and the code pieces together an email (that will send all 4 files at once).

Here's my problem. The MIME code works partially - it sends an html email, but there's only ONE attachment (the first file). If I look at the code for the email, I can see the data for the other three file (plus the MIME description).

I thought you only had to list the four files, one after the other, when creating a MIME email. Is there something else I need to do? Do I need to tell the email that there's more than one attachment? If so, please let me know how.

Jabbamonkey


if ($numberfiles >= 1) // NUMBER OF FILES SUBMITTED
{
for($i = 0; $i < $numberfiles; $i++) // COUNT THROUGH FILES
{
${"data$countin[$i]"} = fread($thefile,filesize($fileonserver));

$email_message2 = $email_message2 .
"Content-Type: " . ${"userfile$countin[$i]_type"} . ";\n" .
" name=\"" . ${"userfile$countin[$i]_name"} . "\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment;\n" .
" filename=\"" . ${"userfile$countin[$i]_name"} . "\"\n\n" .
${"data$countin[$i]"} . "\n\n" .
"--{$mime_boundary}--\n";
}
}