Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/11/2013, 14:57
pablocba26
 
Fecha de Ingreso: noviembre-2013
Mensajes: 4
Antigüedad: 10 años, 5 meses
Puntos: 0
Pregunta Código para insertar archivo adjunto

Que tal, hice un formulario de contacto con archivo adjunto, todos los campos funcionan ok pero adjunto el archivo y no se que codigo php poner para que llegue el archivo adjunto. Paso los codigos html y php para ver si me pueden dar una solucion. Gracias.

El HTML:

<form action="recibe3.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="461" height="344" border="0" cellpadding="0" cellspacing="2">
<tr>
<td height="24" colspan="2" align="center" bgcolor="#90627C"><img src="images/rrhh/proftop.jpg" width="458" height="100" /><br></td>
</tr>
<tr>
<td height="24" align="right">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="164" height="24" align="right"><span class="Estilo3">Nombre y Apellido: </span></td>
<td width="292"><input name="cf_nombre" type="text" id="nombre" size="40" /></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Nacionalidad:</span></td>
<td><label>
<input name="cf_nacionalidad" type="text" id="cf_nacionalidad" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Fecha de Nacimiento: </span></td>
<td><label>
<input name="cf_fecha" type="text" id="cf_fecha" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">E-mail:</span></td>
<td><label>
<input name="cf_mail" type="text" id="cf_mail" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Tel&eacute;fono:</span></td>
<td><label>
<input name="cf_telefono" type="text" id="cf_telefono" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Domicilio:</span></td>
<td><label>
<input name="cf_domicilio" type="text" id="cf_domicilio" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Ciudad:</span></td>
<td><label>
<input name="cf_ciudad" type="text" id="cf_ciudad" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Provincia:</span></td>
<td><label>
<input name="cf_provincia" type="text" id="cf_provincia" size="40" />
</label></td>
</tr>
<tr>
<td height="24" align="right"><span class="Estilo3">Area de Inter&eacute;s: </span></td>
<td><label>
<input name="cf_area" type="text" id="cf_area" size="40" />
</label></td>
</tr>
<tr>
<td height="26" align="right"><span class="Estilo3">Adjuntar CV: </span></td>
<td><label>
<input type="file" name="cf_adjunto" id="cf_adjunto" />
</label></td>
</tr>
<tr>
<td height="26" align="right">&nbsp;</td>
<td><label>
<input type="submit" name="Submit" value="Enviar" />
</label></td>
</tr>
</table>
</form>

El PHP que es lo que me está haciendo falta:
<?php
$field_nombre = $_POST['cf_nombre'];
$field_nacionalidad = $_POST['cf_nacionalidad'];
$field_fecha = $_POST['cf_fecha'];
$field_mail = $_POST['cf_mail'];
$field_telefono = $_POST['cf_telefono'];
$field_domicilio = $_POST['cf_domicilio'];
$field_ciudad = $_POST['cf_ciudad'];
$field_provincia = $_POST['cf_provincia'];
$field_area = $_POST['cf_area'];

$mail_to = '[email protected]';
$subject = 'Mensaje recibido desde formulario web de '.$field_name;

$body_message = 'De: '.$field_nombre."\n";
$body_message .= 'Nacionalidad: '.$field_nacionalidad."\n";
$body_message .= 'Fecha de Nacimiento: '.$field_fecha."\n";
$body_message .= 'Email: '.$field_mail."\n";
$body_message .= 'Tel: '.$field_telefono."\n";
$body_message .= 'Domicilio: '.$field_domicilio."\n";
$body_message .= 'Ciudad: '.$field_ciudad."\n";
$body_message .= 'Provincia: '.$field_provincia."\n";
$body_message .= 'Area: '.$field_area."\n";



$headers = 'From: '.$field_nombre."\r\n";
$headers .= 'Reply-To: '.$field_mail."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Gracias por comunicarse con nosotros. Muy pronto nos pondremos en contacto con usted.');
window.location = 'xxxxxx.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Error. Por favor enviar mail a [email protected]');
window.location = 'contacto.html';
</script>
<?php
}
?>

Desde ya muchas gracias.

Última edición por pablocba26; 13/11/2013 a las 15:08