dongyu2764 2013-01-19 20:40
浏览 72
已采纳

在电子邮件发送之前,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."

";
  • 写回答

1条回答 默认 最新

  • doulianqi3870 2013-01-19 20:53
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度