Avatar Image
Usuario habitual
Usuario habitual

Tengo un codigo que me va perfecto que es el siguiente:

<html>
<head>
<title>Mándanos tus comentarios</title>
</head>

<body bgcolor="#cccc66" text="#003300" link="#006060" vlink="#006060">
<?
if (!$HTTP_POST_VARS){
?>
<form action="envia_form_php.php" method=post>
Nombre: <input type=text name="nombre" size=16>
<br>
Email: <input type=text name=email size=16>
<br>
Comentarios: <textarea name=coment cols=32 rows=6></textarea>
<br>
<input type=submit value="Enviar">
</form>
<?
}else{
//Estoy recibiendo el formulario, compongo el cuerpo
$cuerpo = "Formulario enviado\n";
$cuerpo .= "Nombre: " . $HTTP_POST_VARS["nombre"] . "\n";
$cuerpo .= "Email: " . $HTTP_POST_VARS["email"] . "\n";
$cuerpo .= "Comentarios: " . $HTTP_POST_VARS["coment"] . "\n";

//mando el correo...
mail("josejs@saxspain.com","Formulario recibido",$cuerpo);

//doy las gracias por el envío
echo "Gracias por rellenar el formulario. Se ha enviado correctamente.";
}
?>
</body>
</html>

Funciona perfectamente, y me llega al email bien, pero yo lo que quiero hacer esque a este formulario agregarle un campo de archivo adjunto, para que me lleguen tambien los archivos, fotos.. a mi email. He buscado en el foro y no lo he encontrado.

Gracias de antemano

Avatar Image
@man / @woman
@man / @woman

Checa estos scripts -----> http://electros.net/scripts/c/12

LóciamCorp

Alojamiento, Dominios, Resellers, Servidores Dedicados y Diseño Web. Web Hosting para México, si eres nuevo pero sabes hacer sitios y requieres un servicio profesional y amable, visitanos.
Avatar Image
Usuario habitual
Usuario habitual

Se va a llamar: f_attach.php

<title>COLABORACIÓN</title>

<form enctype="multipart/form-data" name=doit action="env_attach.php" method=POST>
<table cellpadding=0 cellspacing=0 width="295"><tr>
<td width="295" height="26"> <font face="Arial, Helvetica, sans-serif" size="2"><b>Tu
nombre:<br>
</b></font>
<input type="text" name="name" size=30><br>
&nbsp;</td>
</tr>
<tr>
<td width="295"> <font face="Arial, Helvetica, sans-serif" size="2"><b>Tu
e-mail:<br>
</b></font>
<input type="text" name="from" size=30><br>
&nbsp;</td>
</tr>
<tr>
<td width="295"> <font face="Arial, Helvetica, sans-serif" size="2"><b>Archivo:<br>
</b></font>
<input type=file name="attach" size=30><br>
&nbsp;</td>
</tr>
<td width="295">
<tr>
<td width="295" height="23"><font face="Arial, Helvetica, sans-serif" size="2"><b>Asunto:<br>
</b></font>
<input type="text" name="subject" size=30> <br>
&nbsp;</td>
</tr></table>
<p align="left">
<font face="Arial, Helvetica, sans-serif" size="2"><b>Mensaje:</b></font><br>
<textarea name="body" rows=10 cols=35 wrap="message"></textarea><br><br>
<input type="submit" name="sendmail" value="enviar"> </p>
</form>


este otro archivo procesa los datos se va a llamar: env_attach.php


<?
$mailheaders = "Return-Path: $fromn";
$mailheaders .= "From: $fromn";
$mailheaders .= "name: $namen";
//$mailheaders = "From: $fromn";
$mailheaders .= "X-Mailer: Expresateweb Email Interfacen";
$msg_body = stripslashes($body);
if ($attach != "none&quotGiño
{
$file = fopen($attach, "r&quotGiño;
$contents = fread($file, $attach_size);
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
$mailheaders .= "MIME-version: 1.0n";
$mailheaders .= "Content-type: multipart/mixed; ";
$mailheaders .= "boundary="Message-Boundary"n";
$mailheaders .= "Content-transfer-encoding: 7BITn";
$mailheaders .= "X-attachments: $attach_name";
$body_top = "--Message-Boundaryn";
$body_top .= "Content-type: text/plain; charset=US-ASCIIn";
$body_top .= "Content-transfer-encoding: 7BITn";
$body_top .= "Content-description: Mail message bodynn";
$msg_body = $body_top . $msg_body;
$msg_body .= "nn--Message-Boundaryn";
$msg_body .= "Content-type: $attach_type; name="$attach_name"n";
$msg_body .= "Content-Transfer-Encoding: BASE64n";
$msg_body .= "Content-disposition: attachment; filename="$attach_name"nn";
$msg_body .= "$encoded_attachn";
$msg_body .= "--Message-Boundary--n";
}
$extra="-f".$from;
mail("", stripslashes($subject), $msg_body, $mailheaders, $extra);
echo "<h3>GRACIAS POR TU COLABORACIÓN</h3>";
?>


MIRA YA HE MIRADO LA PÁGINA Y HE ENCONTRADO ESTE CODIGO, LO QUE PASA, QUE NO SE DONDE PONER MI EMAIL, PARA QUE ME LLEGE A MI CORREO.

GRACIAS.

ATENCIÓN: Este tema no tiene actividad desde hace más de 6 MESES,
te recomendamos abrir un nuevo tema en lugar de responder al actual
Opciones:
Ir al subforo:
Permisos:
TU NO PUEDES Escribir nuevos temas
TU NO PUEDES Responder a los temas
TU NO PUEDES Editar tus propios mensajes
TU NO PUEDES Borrar tus propios mensajes
Temas similares
TemaUsuariosRespuestasVisitasActividad
Por: , el 18/Dic/2005, 17:27
josejjs NoSetup.org12kDec/05
Por: , el 09/Ago/2005, 12:10
Letsirk chavp17kAug/05
Por: , el 11/Mar/2010, 17:13
Rnstzjc Torry_II1531Mar/10
Por: , el 26/Nov/2009, 10:09
Mmahamud PaseanteDelForo exomar2961Dec/09
Por: , el 02/May/2009, 03:59
lgokul PaseanteDelForo bienvvenido22kNov/10