Hola amigo perdón por la demora, estuve realizando unas modificaciones al script y me a funcionado de maravilla. Te paso el código, solo tienes que modificar el mail de la web y un mail de prueba para que te llegue a tí.
index.php
Código HTML:
Ver original<form accept-charset="utf-8" action="enviar.php" class="trabaja" enctype="multipart/form-data" id="formulario" method="post">
<input type="text" id="nombre" name="nombre" value="Nombre" /> <input type="text" id="apellido" name="apellido" value="Apellidos" /> <input type="text" id="email" name="email" value="e-mail" /> <input type="text" id="telefono" name="telefono" value="Telefono" /> <input type="file" id="filead" name="filead" /> <input type="checkbox" id="condiciones" name="condiciones" /> <input type="submit" value="Enviar Formulario" />
enviar.php
Código PHP:
Ver original<?php
if ($_POST){
// Tomas la informacion del archivo subido.
$partes_ruta = pathinfo($_FILES["filead"]["name"]);
// obtenemos el tamaño del archivo subido
$fsize = $_FILES["filead"]["size"];
if($partes_ruta['extension'] == "doc" or $partes_ruta['extension'] == "docx" or $partes_ruta['extension'] == "pdf" and $fsize <= 1516165165 )
{
//MAIL BODY
$body = "
<html>
<head>
<title>Formulario Trabaja con nosotros</title>
</head>
<body style='background:#EEE; padding:30px;'>
<h2 style='color:#767676;'>Trabaja con nosotros</h2>";
$body .= "
<strong style='color:#0090C6;'>Nombre: </strong>
<span style='color:#767676;'>" . $_POST["nombre"] . "</span>";
$body .= "
<strong style='color:#0090C6;'>Apellidos: </strong>
<span style='color:#767676;'>" . $_POST["apellido"] . "</span>";
$body .= "
<strong style='color:#0090C6;'>Email: </strong>
<span style='color:#767676;'>" . $_POST["email"] . "</span>";
$body .= "
<strong style='color:#0090C6;'>Teléfono: </strong>
<span style='color:#767676;'>" . $_POST["telefono"] . "</span>";
$body .= "</body></html>";
$_name=$_FILES["filead"]["name"];
$_type=$_FILES["filead"]["type"];
$_size=$_FILES["filead"]["size"];
$_temp=$_FILES["filead"]["tmp_name"];
if( strcmp($_name, "") ) //FILES EXISTS {
$fp = fopen($_temp, "rb"); $file = fread($fp, $_size);
// MULTI-HEADERS Content-Type: multipart/mixed and Boundary is mandatory.
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; ";
$headers .= "boundary=".$num."\r\n";
$headers .= "--".$num."\n";
// HTML HEADERS
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "".$body."\n";
$headers .= "--".$num."\n";
// FILES HEADERS
$headers .= "Content-Type:application/octet-stream ";
$headers .= "name=\"".$_name."\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Disposition: attachment; ";
$headers .= "filename=\"".$_name."\r\n\n";
$headers .= "".$file."\r\n";
$headers .= "--".$num."--";
}else { //FILES NO EXISTS
// HTML HEADERS
$headers = "From: GME \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
}
// SEND MAIL
mail("[email protected]", "WEB - Trabaja con nosotros" , $body, $headers); // --> Aqui se espesificaran los usuarios.
echo "<div class='ok'>
<strong>El formulario se ha enviado correctamente.</strong></div>";
} else {
print "El tipo de documento no es correcto, recuerde solo se permitern .doc - .docx - .pdf"; exit; }
/*
print $headers; echo "<br>";
print "------------------------------------------------------ <br>";
print $body; exit;*/
}
?>