Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

php file attaching/sending issue

  • 07-02-2005 4: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