Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [php]problema con upload e allegati
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
fulminato1
aLTeRaZioNeGuiTaRVoiCe

User info:
Registered: Oct 2003
Posts: 2809 (0.34 al dì)
Location: a casa.
Corso: comunicazio digital
Anno: secondo?
Time Online: 30 Days, 8:54:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[php]problema con upload e allegati

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

__________________
www.alterazione.com www.andreaforzani.com
www.myspace.com/alterazione
www.myspace.com/festaincravilla

29-06-2005 15:18
Click Here to See the Profile for fulminato1 Click Here to See the Blog of fulminato1 Click here to Send fulminato1 a Private Message Visit fulminato1's homepage! Find more posts by fulminato1 Add fulminato1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fulminato1
aLTeRaZioNeGuiTaRVoiCe

User info:
Registered: Oct 2003
Posts: 2809 (0.34 al dì)
Location: a casa.
Corso: comunicazio digital
Anno: secondo?
Time Online: 30 Days, 8:54:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

allora??
nessuno che mi può aiutare???

__________________
www.alterazione.com www.andreaforzani.com
www.myspace.com/alterazione
www.myspace.com/festaincravilla

29-06-2005 16:34
Click Here to See the Profile for fulminato1 Click Here to See the Blog of fulminato1 Click here to Send fulminato1 a Private Message Visit fulminato1's homepage! Find more posts by fulminato1 Add fulminato1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Col. Kurtz
Cannibale

User info:
Registered: May 2004
Posts: 849 (0.11 al dì)
Location: Cambogia
Corso: Informatica Magistrale
Anno: Ho finito
Time Online: 7 Days, 4:03:47 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ma "AddAttachment" non funziona solo con i file presenti sul server?

__________________
È odio, odio puro, una pietra morta, merda piena di mosche, sorrisi di plastica, vomitarsi dentro... nessuna paura per la paura di aver paura, soldi in tasca e fame in bocca, buonasera e odio negli occhi, non ce la faccio più

Get FreeBSD NOW!
Anch'io voglio estinguermi!

29-06-2005 16:51
Click Here to See the Profile for Col. Kurtz Click here to Send Col. Kurtz a Private Message Find more posts by Col. Kurtz Add Col. Kurtz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fulminato1
aLTeRaZioNeGuiTaRVoiCe

User info:
Registered: Oct 2003
Posts: 2809 (0.34 al dì)
Location: a casa.
Corso: comunicazio digital
Anno: secondo?
Time Online: 30 Days, 8:54:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

esatto!
faccio appunto una copy del file sul server nella stessa cartella dello script ma poi mi allega quel file .tmp di cui parlavo prima. ho provato a mettere una echo subito dopo la copy e mi dice che quel file temp si trova nella cartella C:\PHP\uploadtemp\ !!!

secondo me il problema sta proprio nel fatto che quando faccio l AddAttachment, fisicamente il file ancora non è stato uploadato nella mia cartella ma in quella temporanea, anche se ho anche provato a mettere un if con le condizioni di file_exist, is_readable ecc e mi dice che il file c è!
non so proprio come risolvere sto problema!

__________________
www.alterazione.com www.andreaforzani.com
www.myspace.com/alterazione
www.myspace.com/festaincravilla

29-06-2005 17:02
Click Here to See the Profile for fulminato1 Click Here to See the Blog of fulminato1 Click here to Send fulminato1 a Private Message Visit fulminato1's homepage! Find more posts by fulminato1 Add fulminato1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
yeah
.grande:maestro.

User info:
Registered: Nov 2003
Posts: 1644 (0.20 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Devi usare l'array $_FILES e la funzione move_uploaded_file().
Non ti scrivo codice perchè sono mesi che non programmo in PHP e rischierei di introdurre errori.

Qui spiega proprio come gestire l'invio dei file, è da lì che ho imparato :)

Per la storia del file temp: in pratica quando PHP gestisce gli upload, durante l'esecuzione dello script il file inviato finisce nella directory temporanea e se alla fine dell'esecuzione non è stato spostato, viene cancellato.

Fammi sapere se risolvi o se hai altri problemi :)

[edit] Vorrei aggiungere una nota offtopic: invece di $_REQUEST, usa $_GET o $_POST, così hai più controllo sull'origine dei dati ;)

__________________
?

29-06-2005 20:51
Click Here to See the Profile for yeah Click here to Send yeah a Private Message Find more posts by yeah Add yeah to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fulminato1
aLTeRaZioNeGuiTaRVoiCe

User info:
Registered: Oct 2003
Posts: 2809 (0.34 al dì)
Location: a casa.
Corso: comunicazio digital
Anno: secondo?
Time Online: 30 Days, 8:54:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by yeah
Devi usare l'array $_FILES e la funzione move_uploaded_file().
Non ti scrivo codice perchè sono mesi che non programmo in PHP e rischierei di introdurre errori.

Qui spiega proprio come gestire l'invio dei file, è da lì che ho imparato :)

Per la storia del file temp: in pratica quando PHP gestisce gli upload, durante l'esecuzione dello script il file inviato finisce nella directory temporanea e se alla fine dell'esecuzione non è stato spostato, viene cancellato.

Fammi sapere se risolvi o se hai altri problemi :)

[edit] Vorrei aggiungere una nota offtopic: invece di $_REQUEST, usa $_GET o $_POST, così hai più controllo sull'origine dei dati ;)


usando $_FILES il problema rimane, ripeto non è una questione di upload, quello già funzionava da prima, il problema è che nonostante l'argomento della AddAttachment sia lo stesso dell'upload, quindi il file che dopo il comando copy o move_uploaded_file si trova sul server, nella mail come allegato mi ritrovo sempre un file .tmp!

__________________
www.alterazione.com www.andreaforzani.com
www.myspace.com/alterazione
www.myspace.com/festaincravilla

30-06-2005 15:21
Click Here to See the Profile for fulminato1 Click Here to See the Blog of fulminato1 Click here to Send fulminato1 a Private Message Visit fulminato1's homepage! Find more posts by fulminato1 Add fulminato1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Col. Kurtz
Cannibale

User info:
Registered: May 2004
Posts: 849 (0.11 al dì)
Location: Cambogia
Corso: Informatica Magistrale
Anno: Ho finito
Time Online: 7 Days, 4:03:47 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by fulminato1
usando $_FILES il problema rimane, ripeto non è una questione di upload, quello già funzionava da prima, il problema è che nonostante l'argomento della AddAttachment sia lo stesso dell'upload, quindi il file che dopo il comando copy o move_uploaded_file si trova sul server, nella mail come allegato mi ritrovo sempre un file .tmp!


Il file .tmp ha le stesse dimensioni di quello originale?

__________________
È odio, odio puro, una pietra morta, merda piena di mosche, sorrisi di plastica, vomitarsi dentro... nessuna paura per la paura di aver paura, soldi in tasca e fame in bocca, buonasera e odio negli occhi, non ce la faccio più

Get FreeBSD NOW!
Anch'io voglio estinguermi!

30-06-2005 15:23
Click Here to See the Profile for Col. Kurtz Click here to Send Col. Kurtz a Private Message Find more posts by Col. Kurtz Add Col. Kurtz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fulminato1
aLTeRaZioNeGuiTaRVoiCe

User info:
Registered: Oct 2003
Posts: 2809 (0.34 al dì)
Location: a casa.
Corso: comunicazio digital
Anno: secondo?
Time Online: 30 Days, 8:54:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

si, ma sta di fatto che io allego delle immagini e alla fine nella mail ho quello .tmp.

__________________
www.alterazione.com www.andreaforzani.com
www.myspace.com/alterazione
www.myspace.com/festaincravilla

30-06-2005 15:43
Click Here to See the Profile for fulminato1 Click Here to See the Blog of fulminato1 Click here to Send fulminato1 a Private Message Visit fulminato1's homepage! Find more posts by fulminato1 Add fulminato1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ti rispondo frettolosamente perché sono al lavoro, per cui potrei anche aver letto male quello che hai scritto.

Il codice che hai quotato, è tutto in un file? altrimenti mi sa che manca l'attributo action nel tag form

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

30-06-2005 15:52
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Col. Kurtz
Cannibale

User info:
Registered: May 2004
Posts: 849 (0.11 al dì)
Location: Cambogia
Corso: Informatica Magistrale
Anno: Ho finito
Time Online: 7 Days, 4:03:47 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Potrebbe essere una questione di "content-type: image/jpg"?

__________________
È odio, odio puro, una pietra morta, merda piena di mosche, sorrisi di plastica, vomitarsi dentro... nessuna paura per la paura di aver paura, soldi in tasca e fame in bocca, buonasera e odio negli occhi, non ce la faccio più

Get FreeBSD NOW!
Anch'io voglio estinguermi!

30-06-2005 16:00
Click Here to See the Profile for Col. Kurtz Click here to Send Col. Kurtz a Private Message Find more posts by Col. Kurtz Add Col. Kurtz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Col. Kurtz
Potrebbe essere una questione di "content-type: image/jpg"?

Anche io all'inizio avevo avanzato la tua stessa ipotesi, ma suppongo che la coonversione avvenga nella classe AddAttachment.

Vediamo che dice fulminato :)

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

30-06-2005 16:08
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fulminato1
aLTeRaZioNeGuiTaRVoiCe

User info:
Registered: Oct 2003
Posts: 2809 (0.34 al dì)
Location: a casa.
Corso: comunicazio digital
Anno: secondo?
Time Online: 30 Days, 8:54:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

l action l ho aggiunto dopo:

enctype="multipart/form-data"

esattamente uguale ad un altro form funzionanet che utilizzo per gli upload.

ma il problema rimane.

__________________
www.alterazione.com www.andreaforzani.com
www.myspace.com/alterazione
www.myspace.com/festaincravilla

30-06-2005 16:29
Click Here to See the Profile for fulminato1 Click Here to See the Blog of fulminato1 Click here to Send fulminato1 a Private Message Visit fulminato1's homepage! Find more posts by fulminato1 Add fulminato1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

e che valore gli hai dato?

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

30-06-2005 16:34
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Col. Kurtz
Cannibale

User info:
Registered: May 2004
Posts: 849 (0.11 al dì)
Location: Cambogia
Corso: Informatica Magistrale
Anno: Ho finito
Time Online: 7 Days, 4:03:47 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by DeepBlue
Anche io all'inizio avevo avanzato la tua stessa ipotesi, ma suppongo che la coonversione avvenga nella classe AddAttachment.

Vediamo che dice fulminato :)


La documentazione di php-mailer non dice niente.
Tentar non nuoce.

__________________
È odio, odio puro, una pietra morta, merda piena di mosche, sorrisi di plastica, vomitarsi dentro... nessuna paura per la paura di aver paura, soldi in tasca e fame in bocca, buonasera e odio negli occhi, non ce la faccio più

Get FreeBSD NOW!
Anch'io voglio estinguermi!

30-06-2005 17:13
Click Here to See the Profile for Col. Kurtz Click here to Send Col. Kurtz a Private Message Find more posts by Col. Kurtz Add Col. Kurtz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
yeah
.grande:maestro.

User info:
Registered: Nov 2003
Posts: 1644 (0.20 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged


usando $_FILES il problema rimane, ripeto non è una questione di upload, quello già funzionava da prima, il problema è che nonostante l'argomento della AddAttachment sia lo stesso dell'upload, quindi il file che dopo il comando copy o move_uploaded_file si trova sul server, nella mail come allegato mi ritrovo sempre un file .tmp!

Ma move_uploaded_file() l'hai usato? Nel codice che hai postato non lo vedo...

__________________
?

30-06-2005 21:16
Click Here to See the Profile for yeah Click here to Send yeah a Private Message Find more posts by yeah Add yeah to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 03:30.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.054 seconds (70.51% PHP - 29.49% MySQL) con 23 query.