Leí mucho sobre este tema en las FAQs, y llegué a este codigo que les pongo abajo que manda un attach por php....ahora quiero que sean 3 adjuntos en lugar de uno, pero no me doy cuenta como agregarlo al mismo codigo que tengo.....¿alguien podra explicarmelo?
ESte es el html
Código HTML:
<form name="filepost" method="post" action="file.php" enctype="multipart/form-data" id="file"> <table width="300" border="0" cellspacing="0" cellpadding="0"> <tr valign="bottom"> <td height="20"><div align="left">Nombre:</div></td> </tr> <tr> <td><div align="left"> <input name="from" type="text" id="from" size="30"> </div></td> </tr> <tr valign="bottom"> <td height="20"><div align="left">Teléfono:</div></td> </tr> <tr valign="bottom"> <td height="20"><div align="left"><span class="frmtxt2"> <input name="telefono" type="text" id="telefono" size="30" /> </span></div></td> </tr> <tr valign="bottom"> <td height="20"><div align="left">E-mail:</div></td> </tr> <tr> <td class="frmtxt2"><div align="left"> <input name="emaila" type="text" id="emaila" size="30"> </div></td> </tr> <tr> <td height="20" valign="bottom"><div align="left">FotoRegalo:</div></td> </tr> <tr> <td height="20" valign="bottom"><label> <div align="left"> <select name="regalo" id="regalo"> <option selected="selected">Taza</option> <option>Calendario</option> <option>Almanaque</option> <option>Remera</option> <option>Fotomontaje</option> <option>Estampado de CD</option> <option>Azulejo</option> <option>Almohadón</option> <option>Rompecabezas</option> <option>Posavasos</option> <option>Llavero</option> <option>Mouse Pad</option> <option>Otro Fotoregalo</option> </select> </div> </label></td> </tr> <tr> <td height="20" valign="bottom"><div align="left">Imagenes para el FotoRegalo:</div></td> </tr> <tr valign="bottom"> <td valign="bottom"><div align="left"> <input name="filea" type="file" id="filea" size="16"> <input name="fileb" type="file" id="fileb" size="16"> <input name="filec" type="file" id="filec" size="16"> </div></td> </tr> <tr> <td height="40" valign="middle"> <div align="center"> <input name="Reset2" type="reset" id="Reset2" value="Borrar"> <input name="Submit2" type="submit" value="Enviar" onClick="return CheckData45()"> </div></td> </tr> </table> </form>
Código PHP:
<?php
if ($filea)
{
function mail_attachment ($from , $to, $subject, $message, $attachment){
$fileatt = $attachment; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
$fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment
$email_from = $from; // Who the email is from
$subject = "Pedido de FotoRegalo";
$email_subject = $subject; // The Subject of the email
$email_txt = $message; // Message that the email has in it
$email_to = $to; // Who the email is to
$headers = "From: ".$email_from;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$msg_txt="\n\n Has recibido un pedido de FotoRegalo de $from";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_txt .= $msg_txt;
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_txt . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$ok = mail($email_to, $email_subject, $email_message, $headers);
if($ok)
{
echo "Su email fue enviado con éxito. Gracias por su pedido. Nos comunicaremos a la brevedad.";
unlink($attachment); // delete a file after attachment sent.
}
else
{
die("Lo sentimos! Su pedido no pudo ser concretado. Por favor, intentelo nuevamente!");
}
}
move_uploaded_file($_FILES["filea"]["tmp_name"],'temp/'.basename($_FILES['filea']['name']));
mail_attachment("$from", "[email protected]", "subject", "message", ("temp/".$_FILES["filea"]["name"]));
}
?>
Muchisimas gracias por anticipado