我正在创建一个电子邮件表单,我可以附加图像作为附件。目前我正在将文件上传到临时目录,然后删除图像,如下所示:
$config['upload_path'] = './temp/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
但是,我正在尝试将图像保存到缓冲区字符串中,并将其附加到电子邮件中,如Userguide所述:
$this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf');
我无法将图像数据转换为字符串。
有什么建议吗?我真的找不到任何东西。
答案 0 :(得分:0)
在这种情况下,我认为你不需要使用缓冲区。只需通过上传的文件名/路径附加文件。
$this->email->attach($this->upload->data('full_path'), 'attachment', 'report.pdf', 'application/pdf');