Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php file attaching/sending issue

  • 07-02-2005 05:05PM
    #1
    Registered Users, Registered Users 2 Posts: 252 ✭✭


    Hi

    Im using a script to send a file to the site admin.
    It works locally (php 4.3.4) but does not on the remote server (php 4.3.10).
    In fact on the remote it does send the mail with the data from the input fields but there is no file attached instead its got this :



    --==Multipart_Boundary_x206067939527cd5646ed2a4c53bdf6c3x
    Content-Type: application/msword;
    name="article st malo.doc"
    Content-Disposition: attachment;
    filename="alo.doc"
    Content-Transfer-Encoding: base64

    0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAJwAAAAAAAAAA
    EAAAKQAAAAEAAAD+////AAAAACYAAAD/////////////////////////////////////////
    EAAAKQAAAAEAAAD+////
    ////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////


    anyone know what may be wrong? is the problem the difference in php versions?


    Tnx


    for reference here is the code relative to sending the file

    [PHP]
    // Obtain file upload vars
    $fileatt = $_FILES;
    $fileatt_type = $_FILES;
    $fileatt_name = $_FILES;
    $message="";
    $data="";


    if (is_uploaded_file($fileatt)) {
    // Read the file to be attached ('rb' = read binary)
    $file = fopen($fileatt,'rb');
    $data = fread($file,filesize($fileatt));
    fclose($file);
    }



    // Base64 encode the file data
    $data = chunk_split(base64_encode($data));


    $headers .= "\nMIME-Version: 1.0\n" .
    "Content-Type: multipart/mixed;\n" .
    " boundary=\"{$mime_boundary}\"";


    $msg .= _JL_RECEIVED_APPLICATION;

    // Add a multipart boundary above the plain message
    $message = "This is a multi-part message in MIME format.\n\n" .
    "--{$mime_boundary}\n" .
    "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
    "Content-Transfer-Encoding: 7bit\n\n".
    $msg . "\n\n";



    // Add file attachment to the message
    $message .= "--{$mime_boundary}\n" . " Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" .
    "Content-Disposition: attachment;\n" .
    " filename=\"{$fileatt_name}\"\n" .
    "Content-Transfer-Encoding: base64\n\n" .
    $data . "\n\n".
    "--{$mime_boundary}--\n";

    [/PHP]


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    I dont have a solution to your problem, but I do have a question - why are you bothering to read the information into $data


    Personally I would have uploaded the file to a temp folder, attached it to an email, then cleared out the temp folder - done and dusted

    Also have a good look http://ie2.php.net/manual/en/function.mail.php - it may have the solution you require


Advertisement