FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18579&edit=1

ID: 18579
Updated by: ruediger.bente@gmx.de
Reported By: ruediger dot bente at gmx dot de
Summary: Can't get the filename of an attachment
Status: Open
Type: Bug
Package: Mail_mimeDecode
Operating System: Linux (Ubuntu-Server)
Package Version: 1.5.5
PHP Version: 5.3.1
Roadmap Versions:
New Comment:

duplicate of #18579


Previous Comments:
------------------------------------------------------------------------

[2011-06-01 14:29:14] ruebezahl

Description:
------------
$part->ctype_parameters['filename'] has no valid value or is blank.

Mimepart of the attachement looks like this:

--------------060808080706060305030508
Content-Type: application/pdf;
name="=?UTF-8?B?QmVrbGVpZHVuZ3NtYcOfZS5wZGY=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename*0*=UTF-8''%42%65%6B%6C%65%69%64%75%6E%67%73%6D%61%C3%9F%65%2E%70;
filename*1*=%64%66

JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0
ZURlY29kZT4+CnN0cmVhbQp4nM2dS6/uNnam5/4VexzAO5JIiRJgHKBcrmqgZ5UYyCDILJ0G
.......

Mail was sent by Thunderbird 3.1.10

Test script:
---------------
require_once 'Mail/mimeDecode.php';

$input = file_get_contents("/tmp/druckmessage");
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $input;
$structure = Mail_mimeDecode::decode($params);

foreach ($structure->parts as $part)
{
// only save if an attachment
if (isset($part->disposition) and
($part->disposition=='attachment'))
{
// open file
$fp = fopen($part->ctype_parameters['filename'], 'w');
// write body
fwrite($fp, $part->body);
// close file
fclose($fp);
}
}

Expected result:
----------------
Like to get the filename out of the mimepart header

Actual result:
--------------
filename is blank

after adding a
print_r($structure->ctype_parameters);
before the foreach
and a
print($part->ctype_primary . ' // ' . $part->disposition);
after the foreach
the result is the following:

Array
(
[boundary] => ------------060808080706060305030508
)
text //
application // attachment

------------------------------------------------------------------------

Search Discussions

  • Ruediger Bente at Jun 1, 2011 at 1:34 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18579&edit=1

    ID: 18579
    Updated by: ruediger.bente@gmx.de
    Reported By: ruediger dot bente at gmx dot de
    Summary: Can't get the filename of an attachment
    -Status: Open
    +Status: Duplicate
    Type: Bug
    Package: Mail_mimeDecode
    Operating System: Linux (Ubuntu-Server)
    Package Version: 1.5.5
    PHP Version: 5.3.1
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Duplicate



    Previous Comments:
    ------------------------------------------------------------------------

    [2011-06-01 14:33:20] ruebezahl

    duplicate of #18579

    ------------------------------------------------------------------------

    [2011-06-01 14:29:14] ruebezahl

    Description:
    ------------
    $part->ctype_parameters['filename'] has no valid value or is blank.

    Mimepart of the attachement looks like this:

    --------------060808080706060305030508
    Content-Type: application/pdf;
    name="=?UTF-8?B?QmVrbGVpZHVuZ3NtYcOfZS5wZGY=?="
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment;
    filename*0*=UTF-8''%42%65%6B%6C%65%69%64%75%6E%67%73%6D%61%C3%9F%65%2E%70;
    filename*1*=%64%66

    JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0
    ZURlY29kZT4+CnN0cmVhbQp4nM2dS6/uNnam5/4VexzAO5JIiRJgHKBcrmqgZ5UYyCDILJ0G
    .......

    Mail was sent by Thunderbird 3.1.10

    Test script:
    ---------------
    require_once 'Mail/mimeDecode.php';

    $input = file_get_contents("/tmp/druckmessage");
    $params['include_bodies'] = true;
    $params['decode_bodies'] = true;
    $params['decode_headers'] = true;
    $params['input'] = $input;
    $structure = Mail_mimeDecode::decode($params);

    foreach ($structure->parts as $part)
    {
    // only save if an attachment
    if (isset($part->disposition) and
    ($part->disposition=='attachment'))
    {
    // open file
    $fp = fopen($part->ctype_parameters['filename'], 'w');
    // write body
    fwrite($fp, $part->body);
    // close file
    fclose($fp);
    }
    }

    Expected result:
    ----------------
    Like to get the filename out of the mimepart header

    Actual result:
    --------------
    filename is blank

    after adding a
    print_r($structure->ctype_parameters);
    before the foreach
    and a
    print($part->ctype_primary . ' // ' . $part->disposition);
    after the foreach
    the result is the following:

    Array
    (
    [boundary] => ------------060808080706060305030508
    )
    text //
    application // attachment

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJun 1, '11 at 1:34p
activeJun 1, '11 at 1:34p
posts2
users1
websitepear.php.net

1 user in discussion

Ruediger Bente: 2 posts

People

Translate

site design / logo © 2022 Grokbase