[php]problema con upload e allegati
Posted by fulminato1 on 29-06-2005 15:18
ho un problema con questo script:


code:
PHP:

<?php
if ($_REQUEST['Invia']) {
        
//echo $file;
        //aggiungo gli allegati
        
copy("$file","$file_name");
        include (
"class.phpmailer.php");
        
//creazione istanza phpmailer
        
$mail = new phpmailer();
        
//seleziona il protocollo SMTP come modalità di spedizione
        
$mail->IsSMTP();
        
//nome dominio
        
$mail->Host "smtp.nuovacarrozzeriastella.it";
            
//segnala che è richiesta l autenticazione
        
$mail->SMTPAuth TRUE;
        
//indicazione nome utente e password
        
$mail->Username 'preventivi@nuovacarrozzeriastella.it';
        
$mail->Password '***';
        
//mittente
        
$mail->From $_REQUEST['From'];
        
$mail->FromName $_REQUEST['FromName'];
        
//$mail->From = "preventivi@nuovacarrozzeriastella.it";
        //$mail->FromName = "preventivi stella";
        //destinatario
        //$mail->AddAddress($_REQUEST['TO'], $_REQUEST['ToName']);
        
$mail->AddAddress('preventivi@nuovacarrozzeriastella.it');
        
//aggiungo gli allegati
        //@copy("$file","foto/$file_name");
        //$mail->AddAttachment('68.png');
        
$mail->AddAttachment($file);
        
//echo $file1."<br>";
        //$mail->AddAttachment($file2);
        //echo $file2."<br>";
        //$mail->AddAttachment($file3);
        //echo $file3."<br>";
        //oggetto e testo del messaggio
        
$mail->Subject $_REQUEST['Subject'];
        
$mail->Body $_REQUEST['Message'];
             
//formato testo o html
        
$mail->IsHTML = (boolean) $_REQUEST['FormatoHTML'];
        if(
$mail->IsHTML$mail->AltBody =     strip_tags($_REQUEST['Message']);
        if(
$mail->Send()) {
            echo 
"<h2><p>Messaggio inviato con successo!</p></h2>";
        } else {
            echo 
"<p>Errore: ".$mail->ErrorInfo."</p>";
        }
    
}
?>

<form method="post" enctype="multipart/form-data"> <table> <tr> <td>Nome del mittente: </td> <td><input type="text" name="FromName" size="40" value="<?= htmlspecialchars($_REQUEST['FromName']) ?>"></td> </tr> <tr> <td>Email del mittente: </td> <td><input type="text" name="From" size="40" value="<?= htmlspecialchars($_REQUEST['From']) ?>"></td> </tr> <!--<tr> <td>Nome del destinatario: </td> <td><input type="text" name="ToName" size="40" value="<?= htmlspecialchars($_REQUEST['ToName']) ?>"></td> </tr> <tr> <td>Email del destinatario: </td> <td><input type="text" name="To" size="40" value="<?= htmlspecialchars($_REQUEST['To']) ?>"></td> </tr> --> <tr> <td>Oggetto: </td> <td><input type="text" name="Subject" size="40" value="<?= htmlspecialchars($_REQUEST['Subject']) ?>"></td> </tr> <tr> <td>Messaggio: </td> <td><textarea name="Message" rows="7" cols="40"><?= htmlspecialchars($_REQUEST['Message']) ?></textarea></td> </tr> <!--<tr> <td></td> <td><input type="checkbox" name="FormatoHTML" <?= $_REQUEST['FromatoHTML'] ? 'checked="yes"' : '' ?>> Invia in formato HTML</td> </tr> --> <tr> <td>Pima foto: </td> <td><input type="file" name="file" size="40"></td> </tr> <!--<tr> <td>Seconda foto: </td> <td><input type="file" name="file2" size="40"></td> </tr> <tr> <td>Terza foto: </td> <td><input type="file" name="file2" size="40"></td> </tr> --> <tr> <td></td> <td><input type="submit" name="Invia" value="Invia messaggio"></td> </tr> </table> </form>



anche se l'istruzione copy va a buon fine, ovvero il file viene uploadato correttamente, quando mi arriva la mail come allegato c è un file chiamato "php(4 numeri).tmp", ninte a che fare con quello originale che volevo inviare.
Partendo dl fatto che sia il comando copy che il comando AddAttachment funzionano correttamente, l'unica cosa che mi è venuta in mente è che quando lo script arriva a AddAttachment probabilmente il file allegato ancora non è stato completamente uploadato.

Come posso risolvere il problema??

Grazie in anticipo
Powered by: vbHome (lite) v3.8 and vBulletin v2.3.1
Copyright © 2000 - 2002 Jelsoft Enterprises Limited