Ver Mensaje Individual
  #8 (permalink)  
Antiguo 12/01/2011, 08:13
Avatar de alfarock
alfarock
 
Fecha de Ingreso: agosto-2008
Ubicación: Carolina, Puerto Rico
Mensajes: 24
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Enviar datos del formulario con adjunto

Toma esta forma de enviar un email con cualquier adjunto ok

Código HTML:
<form name='formulario' id='formulario' method='post' action='empleo_envio.php' target='_self' enctype="multipart/form-data">
<table width="536" border="0" cellspacing="0" cellpadding="0" rightpadding="10">
  <tr>
    <td width="118" height="34"><p class="formulario">Nombre:
      </p></td>
    <td width="418"><span class="formulario">
      <input type='text' name='Nombre' id='Nombre' /></span></td>
    </tr>
  <tr>
    <td height="38"><span class="formulario">E-mail:</span></td>
    <td><span class="formulario">
      <input type='text' name='email' id='email' />
    </span></td>
    </tr>
  <tr>
    <td height="36"><span class="formulario">Asunto:</span></td>
    <td><span class="formulario">
      <input type='text' name='asunto' id='asunto' />
    </span></td>
    </tr>
  <tr>
    <td valign="top"><span class="formulario">Mensaje:</span></td>
    <td><span class="formulario">
      <textarea name="mensaje" cols="50" rows="10" id="mensaje"></textarea>
    </span></td>
    </tr>
  <tr>
    <td><span class="formulario">Adjuntar archivo:</span></td>
    <td><span class="formulario">
      <input type='file' name='archivo1' id='archivo1' />
    </span></td>
    </tr>
  <tr>
    <td height="24" colspan="2"><span class="formulario">
      <input type='submit' value='Enviar' />
    </span></td>
    </tr>
</table>
</form> 
aqui tienes el php

Código PHP:
<?php 
function form_mail($sPara$sAsunto$sTexto$sDe)

$bHayFicheros 0
$sCabeceraTexto ""
$sAdjuntos ""

if (
$sDe)$sCabeceras "From:".$sDe."\n"
else 
$sCabeceras ""
$sCabeceras .= "MIME-version: 1.0\n"
foreach (
$_POST as $sNombre => $sValor
$sTexto $sTexto."\n".$sNombre." = ".$sValor

foreach (
$_FILES as $vAdjunto)

if (
$bHayFicheros == 0)

$bHayFicheros 1
$sCabeceras .= "Content-type: multipart/mixed;"
$sCabeceras .= "boundary=\"--_Separador-de-mensajes_--\"\n"

$sCabeceraTexto "----_Separador-de-mensajes_--\n"
$sCabeceraTexto .= "Content-type: text/plain;charset=iso-8859-1\n"
$sCabeceraTexto .= "Content-transfer-encoding: 7BIT\n"

$sTexto $sCabeceraTexto.$sTexto

if (
$vAdjunto["size"] > 0)

$sAdjuntos .= "\n\n----_Separador-de-mensajes_--\n"
$sAdjuntos .= "Content-type: ".$vAdjunto["type"].";name=\"".$vAdjunto["name"]."\"\n";; 
$sAdjuntos .= "Content-Transfer-Encoding: BASE64\n"
$sAdjuntos .= "Content-disposition: attachment;filename=\"".$vAdjunto["name"]."\"\n\n"

$oFichero fopen($vAdjunto["tmp_name"], 'r'); 
$sContenido fread($oFicherofilesize($vAdjunto["tmp_name"])); 
$sAdjuntos .= chunk_split(base64_encode($sContenido)); 
fclose($oFichero); 



if (
$bHayFicheros
$sTexto .= $sAdjuntos."\n\n----_Separador-de-mensajes_----\n"
return(
mail($sPara$sAsunto$sTexto$sCabeceras)); 


//cambiar aqui el email 
if (form_mail("[email protected]"$_POST[asunto], 
"Los datos introducidos en el formulario son:\n\n"$_POST[email])) 
header("Location: pagina de redirigida.php"); 
?>
espero que sea util