[英]How to get the name from content-disposition in MIME::Entity part?
my $Parser = new MIME::Parser;
my $entity = $Parser->parse_data( $body );
my @parts = $entity->parts;
for $part(@parts){
my $type=$part->mime_type;
my $bhandle=$part->bodyhandle;
$header = $part->head();
$content_disp = $header->get('Content-Disposition');
if ($type =~ /text/i){
$bodydata = "";
if (my $io = $part->open("r")) {
while (defined($_ = $io->getline)) {
$bodydata .= $_;
}
$io->close;
print $bodydata;
}
}
}
I think you're looking for the recommended_filename method: 我想你正在寻找的recommended_filename方法:
$header = $part->head();
$filename = $header->recommended_filename;
Be sure to check the return value for sanity. 务必检查返回值是否合理。 Note that it can also be
undef
. 请注意,它也可以是
undef
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.