C
cinewow
1
Iota
Diseñador
Verificación en dos pasos activada
Verificado por Whatsapp
Suscripción a IA
Que tal amigos, me podrian ayudar? lo que pasa es que lo que hice anteriormente fue enviar datos de un formulario a un correo, hasta ahi todo bien, pero el problema surgio cuando quice hacer lo mismo pero complementandolo con un archivo adjunto. Lo que hace ahorita es enviar la imagen pero no el texto que se introduce en el formulario, lo que quiero es que envie las dos cosas (texto y archivo adjunto) pero no lo logro hacer, es una u otra cosa. Me podrian ayudar a identificar el erro de favor? de antemano gracias :encouragement:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Titulo</title>
<script type="text/javascript" src="archivo.js"></script>
</head>
<body>
<?php
include("funcion.php");
?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return validarform(this);">
<h1>QUEJAS Y/O SUGERENCIAS</h1>
<table width="100%" border="0">
<tr>
<td>
<label for="date">Fecha:</label>
<input type="date" name="date" id="date"></td>
</tr>
<tr>
<td>
<label for="textfield">Nombre (s):</label>
<input type="text" name="nombre" id="nombre"></td>
<td><label for="textfield2">Apellido Paterno:</label>
<input type="text" name="apaterno" id="apaterno></td>
<td><label for="textfield3">Apellido Materno:</label>
<input type="text" name="amaterno" id="amaterno"></td>
</tr>
<tr>
<td>
<label for="email">Email:</label>
<input type="email" name="email" id="email"></td>
<td><label for="textfield4">Teléfono:</label>
<input type="text" name="tel" id="tel"></td>
</tr>
<tr>
<td colspan="3"><label for="select">Área a la que va dirigida la queja y/o sugerencia:</label>
<select name="adirigida" id="adirigida">
<option>Opcion1</option>
<option>Opcion2</option>
</select></td>
</tr>
<tr>
<td colspan="3">
<label for="textarea"> Sugerencia:</label>
<textarea name="textarea" id="textarea" cols="60" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="3">
<label for="fileField">Adjuntar Archivo (Evidencia):</label>
<input type="file" name="file" id="file"></td>
</tr>
</table>
<p>
<input type="submit" name="enviar" id="enviar" value="Enviar" />
</p>
<p> </p>
</form>
<?php
if(isset($_POST['enviar'])){ //confirma que se aya dado clic en el buzon
$date=strtoupper(scanear_string($_POST['date'] , "2"));
$nombre=scanear_numerico(strtoupper(scanear_string($_POST['nombre'] , "2")));
$apaterno=scanear_numerico(strtoupper(scanear_string($_POST['apaterno'] , "2")));
$amaterno=scanear_numerico(strtoupper(scanear_string($_POST['amaterno'] , "2")));
$email=strtoupper(scanear_string($_POST['email'] , "1"));
$tel=scanear_letras(strtoupper(scanear_string($_POST['tel'] , "2")));
$adirigida=scanear_numerico(strtoupper(scanear_string($_POST['adirigida'] , "2")));
$textarea=strtoupper(scanear_string($_POST['textarea'] , "2"));
$_name=$_FILES['file']["name"];
$_type=$_FILES['file']["type"];
$_size=$_FILES['file']["size"];
$_temp=$_FILES['file']["tmp_name"];
if( strcmp($_name, "") ) //FILES EXISTS
{
$fp = fopen($_temp, "rb");
$file = fread($fp, $_size);
$file = chunk_split(base64_encode($file));
}
echo 'Tu solicitud se ha Enviado con EXITO! En breve de responderemos...';
// El mensaje
$mensaje='<h1>Bienvenido la solicitud es la Siguiente </h1><br><table width="100%" border="0"><tr><td width="33%"><b>Fecha(año-mes-día):</b></td><td width="67%">'.$date.'</td></tr><tr><td width="33%"><b>Nombre:</b></td><td width="67%"> '.$nombre.' '.$apaterno.' '.$amaterno.'</td></tr><tr><td width="33%"><b>Telefono:</b></td><td width="67%"> '.$tel.'</td></tr><tr><td width="33%"><b>Email:</b></td><td width="67%"> '.$email.'</td></tr><tr><td width="33%"><b>Área a la que va dirigida la queja y/o sugerencia:</b></td><td width="67%"> '.$adirigida.'</td></tr><tr><td width="33%"><b>Queja y/o Sugerencia:</b></td><td width="67%"> '.$textarea.'</td></tr></table>';
// Si cualquier línea es más larga de 70 caracteres, se debería usar wordwrap()
$mensaje = wordwrap($mensaje, 70, "\r\n");
// Para enviar un correo HTML mail, la cabecera Content-type debe fijarse
//Envío en formato HTML
$cabeceras = "MIME-Version: 1.0\r\n";
$cabeceras .= "Content-type: text/html; charset=iso-8859-1\r\n";
$cabeceras .= "Content-Type:application/octet-stream ";
$cabeceras .= "name=\"".$_name."\"r\n";
$cabeceras .= "Content-Transfer-Encoding: base64\r\n";
$cabeceras .= "Content-Disposition: attachment; ";
$cabeceras .= "filename=\"".$_name."\"\r\n\n";
$cabeceras .= "".$file."\r\n";
// Cabeceras adicionales
$cabeceras .= 'To: <xxxxx-xx@hotmail.com > "\r\n"';
$cabeceras .= 'From: <'.$email.'>';
//cabeceras de la imagen
// Send
mail('ejemplo@gmail.com',
'Queja y/o Sugerencia',
$mensaje,
$cabeceras);
}
?>
</body>
</html>