23/10/2015, 08:05
|
| | Fecha de Ingreso: octubre-2015
Mensajes: 2
Antigüedad: 9 años, 1 mes Puntos: 0 | |
Respuesta: Form HTML con envio de 2 files con PHP Muchas Gracias, al final he encontrado la soluccion.
Sigue el PHP correcto por alguen que lo necesita :)
PHP file Código PHP: <?php
$allegato = $_FILES['allegato']['name'];
$allegato2 = $_FILES['allegato2']['name'];
$email = $_POST['email'];
$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$telefono = $_POST['telefono'];
mail_attachment("[email protected]","Subject","Nuova canditatuda da <b>$nome $cognome</b>. <br> Telefono: $telefono <br> Email: $email ",array("allegato","allegato2"));
function mail_attachment($to, $subject, $message, $files) {
$headers = "From: [email protected]";
$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}\"";
$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" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
foreach ($files as $f) {
$file = $_FILES[$f]['tmp_name'];
$filename = $_FILES[$f]['name'];;
$data = file_get_contents($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$file\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$filename\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
echo (@mail($to, $subject, $message, $headers)) ? "<p>Messaggio spedito correttamente a $to!</p>" : "<p>ERRORE! Messaggio non spedito a $to!</p>";
} // mail-attachment
?> |