doulu7921 2016-01-20 06:27
浏览 36
已采纳

Magento电子邮件附件没有收到姓名

I have created a contact us page with email attachment. I followed the tutorial from here: http://www.blog.magepsycho.com/adding-upload-field-in-contact-form-and-send-as-attachment/.

The contact form and attachment works perfectly however there is an issue.

If I intentionally send the form without attaching any file, I still receive a no name attachment file. Suppose to be no attachment present.

screenshot below:

What was wrong with this email attachment?

  • 写回答

1条回答 默认 最新

  • dosryjij88555 2016-02-24 06:25
    关注

    If you try to look on the line 67-73 where it sends the attachment, you will notice the if statement that checks if $attachmentFilePath exist.

    $attachmentFilePath = Mage::getBaseDir('media'). DS . 'contacts' . DS . $fileName;
    if(file_exists($attachmentFilePath)){
    

    This condition returns true even if the user haven't attached anything. If you print $attachmentFilePath, it will give you the full path. When user send email without attachment, $attachmentFilePath it will give you a path until directory contacts.

    Try to update your if condition to this

    if($fileName){
    

    It will check if the field has a value and skip if there's none.

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

报告相同问题?

悬赏问题

  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面