El tema es que quiero adjuntar en mi formulario php varios archivos por ahora puedo adjuntar el primero... pero me pierdo un poco con el codigo...
Código HTML:
Ver original
Esta seria una pequeña parte del formulario donde veis que los campos se llaman ficha[]
después tengo el siguiente codigo que funciona solo para el primer archivo.
Código PHP:
Ver original
<?php $nombre_archivo = $_FILES['ficha']['name']; $tipo_archivo = $_FILES['ficha']['type']; $tamano_archivo = $_FILES['ficha']['size']; $subject = "Contacto"; $mensaje= "---------------------------------- <br />"; $mensaje.= " Contacto <br />"; $mensaje.= "---------------------------------- <br />"; if($_POST['empresa'] != ""){ $mensaje.= "NOMBRE Y APELLIDOS: ".$_POST['empresa']."<br />"; }else{ $_POST['empresa'] == ""; } if($_POST['email'] != ""){ $mensaje.= "EMAIL: ".$_POST['email']."<br />"; }else{ $_POST['email'] == ""; } if($_POST['telefono'] != ""){ $mensaje.= "TELEFONO: ".$_POST['telefono']."<br />"; }else{ $_POST['telefono'] == ""; } if($_POST['marca'] != ""){ $mensaje.= "MARCA: ".$_POST['marca']."<br />"; }else{ $_POST['marca'] == ""; } if($_POST['modelo'] != ""){ $mensaje.= "MODELO: ".$_POST['modelo']."<br />"; }else{ $_POST['modelo'] == ""; } if($_POST['matricula'] != ""){ $mensaje.= "MATRICULA: ".$_POST['matricula']."<br />"; }else{ $_POST['matricula'] == ""; } if($_POST['refpieza'] != ""){ $mensaje.= "REFERENCIA PIEZA: ".$_POST['refpieza']."<br />"; }else{ $_POST['refpieza'] == ""; } $mensaje.= "---------------------------------- <br /><br />"; $mensaje.= $_POST['mensaje']."<br /><br />"; $nombref = $_FILES["ficha"]["name"]; $headers .= "From: ".$_POST['email']."\r\n"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=UTF-8\r\n"; $headers .= "Content-type: multipart/mixed; "; $headers .= "boundary=\"Message-Boundary\"\n"; $headers .= "Content-transfer-encoding: 7BIT\n"; $headers .= "X-attachments: $nombref"; $body_top = "--Message-Boundary\n"; $body_top .= "Content-type: text/html; charset=UTF-8\n"; $body_top .= "Content-transfer-encoding: 7BIT\n"; $body_top .= "Content-description: Mail message body\n\n"; $mensaje = $body_top.$mensaje; if($tamano_archivo>0) { //Leo el fichero //Adjunto el fichero $mensaje .= "\n\n--Message-Boundary\n"; $mensaje .= "Content-type: Binary; name=\"$nombref\"\n"; $mensaje .= "Content-Transfer-Encoding: BASE64\n"; $mensaje .= "Content-disposition: attachment; filename=\"$nombref\"\n\n"; $mensaje .= "$sAdjuntos\n"; $mensaje .= "--Message-Boundary--\n"; } ?>
Espero que no sea mucho lio
Gracias