Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/04/2015, 02:36
Dselling
 
Fecha de Ingreso: enero-2003
Ubicación: Madrid
Mensajes: 136
Antigüedad: 21 años, 3 meses
Puntos: 1
Problma al enviar email con adjunto, a traves de PHPMailer

Tengo problema cuando meto a rellenar los formularios con adjunto de una imagen. Si me recibe a mi correo pero el adjunto no me va y sale el error:

Código:
Notice: Undefined index: adjunto in C:\xampp\htdocs\01PhpProyecto\phpmailer.php on line 8
El archivo creado phpmailer.php

Código PHP:
<?php
$msg 
null;
if(isset(
$_POST["phpmailer"])){
    
$nombre htmlspecialchars($_POST["nombre"]);
    
$email htmlspecialchars($_POST["email"]);
    
$asunto htmlspecialchars($_POST["asunto"]);
    
$mensaje $_POST["mensaje"];
    
$adjunto $_FILES["adjunto"];
    require_once(
"phpmailer/class.phpmailer.php");
    require(
"phpmailer/PHPMailerAutoload.php");
        
$mail = new PHPMailer;
        
$mail->IsSMTP();
        
$mail->SMTPDebug=0;
        
$mail->SMTPAuth=true;        
        
$mail->Host "smtp.fcpv.es";
        
$mail->Username "[email protected]";
        
$mail->Password "CONTRASEÑA";
        
$mail->From "[email protected]";
        
$mail->FromName "Administrador";
        
$mail->Subject $asunto;
        
$mail->addAddress($email$nombre);
        
$mail->msgHTML($mensaje);
        if(
$adjunto["size"] > 0){
            
$mail->addAttachment($adjunto["tmp_name"], $adjunto["name"]);
        }
        
        if(
$mail->Send()){
            
$msg "Enhorabuena email enviado con éxito a $email";
        }
        else {
            
$msg "Ha ocurrido un error al enviar el email a $email";
        }
}
?>
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="iso-5589-1">
    </head>
    <body>
        <h1>Enviar Email con PHPMailer</h1>
        <strong><?php echo $msg?></strong>
        <form method="POST" enctype="multpart/form-data" action="<?php echo $_SERVER['PHP_SELF'?>">
            <table>
                <tr>
                    <td>Nombre del destinatario:</td>
                    <td><input type="text" name="nombre"></td>
                </tr>
                <tr>
                    <td>Email del destinatario:</td>
                    <td><input type="text" name="email"></td>
                </tr>
                <tr>
                    <td>Asunto:</td>
                    <td><input type="text" name="asunto"></td>
                </tr>
                <tr>
                    <td>Adjunta archivo:</td>
                    <td><input type="file" name="adjunto"></td>
                </tr>
                <tr>
                    <td>Mensaje:</td>
                    <td><textarea name="mensaje" cols="30" rows="10"></textarea></td>
                </tr>
            </table>
            <input type="hidden" name="phpmailer">
            <input type="submit" name="Enviar email">
        </form>
    </body>
</html>
La línea 8 está en
Código PHP:
$adjunto $_FILES["adjunto"]; 
¿Cuál debe ser el fallo de adjunto?
__________________
José Daniel Nuño
Informático y desarrollador de Web PHP-MySQL
Fundación Carmen Pardo-Valcarce