Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    Allegato viene letto male

    Ciao a tutti,
    ho letto diversi 3d e provato anche pari pari gli script di freephp da altri ritenuti eccellenti.
    Ho qualche difficoltà quindi a capire perchè al momento dell'apertura dell'allegato ottengo questo errore:



    Penso che un indizio possa essere in questa parte di codice:

    Codice PHP:
    $encoded_attach chunk_split(base64_encode($contents)); 
    ma come operare?


    grazie
    Eccoti!

  2. #2
    Utente di HTML.it L'avatar di chris
    Registrato dal
    Sep 1999
    Messaggi
    1,568
    forse il problema sta nella preparazione della mail. prova ad allegare un po' di codice
    "Nei prossimi tre anni col mio governo vogliamo vincere anche il cancro, che colpisce ogni anno 250.000 italiani e riguarda quasi due milioni di nostri concittadini"

  3. #3
    Codice PHP:
    <?php

    // RENDIAMO LO SCRIPT COMPATIBILE CON LE VERSIONI DI PHP < 4.1.0
    if(!isset($_POST)) $_POST $HTTP_POST_VARS;
    if(!isset(
    $_FILES)) $_FILES $HTTP_POST_FILES;

    // RIPULIAMO I VARI CAMPI DEL MODULO
    $Destinatario trim($_POST["Destinatario"]);
    $Soggetto trim(stripslashes($_POST["Soggetto"]));
    $Contenuto trim(stripslashes($_POST["Contenuto"]));

    // ASSEGNIAMO A VARIABILI PIU' LEGGIBILI, LE PROPRIETA' DELL'ALLEGATO
    $attach $_FILES["allegato"]["tmp_name"];
    $file_name $_FILES["allegato"]["name"];
    $file_type $_FILES["allegato"]["type"];
    $file_size $_FILES["allegato"]["size"];

    // DELIMITATORE
    $boundary md5(uniqid(microtime()));

    // APRIAMO L'ALLEGATO PER LEGGERLO E CODIFICARLO
    $file = @fopen($attach"r");
    $contents = @fread($file$file_size);
    $encoded_attach chunk_split(base64_encode($contents));
    @
    fclose($file);

    // INTESTAZIONI DELLA MAIL
    $mail_headers .= "MIME-version: 1.0\n";
    $mail_headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"";
    $mail_headers .= "X-attachments: $file_name\n";

    // COSTRUIAMO IL CORPO DELLA MAIL
    $mail_body "--$boundary\n";
    $mail_body .= "Content-Type: text/plain; charset=us-ascii\n";
    $mail_body .= "Content-Transfer-Encoding: 7bit\n\n";
    $mail_body .= "$Contenuto\n\n";
    $mail_body .= "--$boundary\n";
    $mail_body .= "Content-type: $file_type; name=\"$file_name\"\n";
    $mail_body .= "Content-Transfer-Encoding: base64\n";
    $mail_body .= "$encoded_attach\n";
    $mail_body .= "--$boundary--\n";

    // INVIO DELLA MAIL
    if(@mail($Destinatario$Soggetto$mail_body$mail_headers)) { // SE L'INVIO E' ANDATO A BUON FINE...

    echo "La mail è stata inoltrata con successo.";

    } else {
    // ALTRIMENTI...

    echo "Si sono verificati dei problemi nell'invio della mail.";

    }

    ?>

    E' pari pari quello di gm
    Eccoti!

  4. #4
    Ho trovato questo in rete

    inally found the answer to my own question....

    I needed to set the following variable before executing the encryption:

    set_magic_quotes_runtime(0);

    The file was corrupted on the new ISP since they have this set to 1 on
    their system and the old ISP had it at 0. This does not parse the
    encryped file with slashes for special characters.
    Eccoti!

  5. #5
    Ecco...

    a me è settato su off però

    provo a fare qualche prova in locale
    Eccoti!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.