在电子邮件发送之前,base64_encode是否重命名我的文件?

I'm using phpexcel to create a file.xls and then this small code i picked up to email me the xls as attachment. the problem is it sends the xls attachment as filename = "._folder1_admin.xls" instead of the actual filename "admin.xls"

It works fine if i define $filename without a sub-directory. but once i use the sub-dir like: $filename = "./folder1/".$contextUser.".xls"; it screws up the filename in email.

i tried html_entity_decode($filename) but that didnt help..

this is the only code i can see it modifying filename before sending email

chunk_split(base64_encode(file_get_contents("$filename")));

heres the whole code anyway:

$filename = "./folder1/".$contextUser.".xls";
$strHeader .= "MIME-Version: 1.0
";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"

";
$strHeader .= "This is a multi-part message in MIME format.
";
$strHeader .= "--".$strSid."
";
$strHeader .= "Content-type: text/html; charset=windows-874
"; // or UTF-8 //
$strHeader .= "Content-Transfer-Encoding: 7bit

";
$strHeader .= $strMessage."

";
$strContent1 = chunk_split(base64_encode(file_get_contents("$filename")));
$strHeader .= "--".$strSid."
";
$strHeader .= "Content-Type: application/octet-stream; name=\"$filename\"
";
$strHeader .= "Content-Transfer-Encoding: base64
";
$strHeader .= "Content-Disposition: attachment; filename=\"$filename\"

";
$strHeader .= $strContent1."

";

Here:

$strHeader .= "Content-Disposition: attachment; filename=\"$filename\"

";

You are setting the filename to the contents of $filenme and since ./folder1/admin.xls is not valid filename, / are normalized to underscores. You may want to use basename($filename) in this place.