使用CodeIgniter将图像转换为缓冲区字符串
问题描述:
我正在创建一个电子邮件表单,我可以将图像作为附件附加。目前,我的文件上传到一个临时目录并aftewards删除相似图片:使用CodeIgniter将图像转换为缓冲区字符串
$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');
我被卡住获取图像数据到字符串。
有什么建议吗?我找不到任何东西。
答
在这种情况下,我不认为你需要使用缓冲区。只需通过上传的文件名/路径附加文件即可。
$this->email->attach($this->upload->data('full_path'), 'attachment', 'report.pdf', 'application/pdf');
允许的类型是GIF,JPG和PNG,但附件是一个PDF? – Samutz 2015-04-02 12:53:10
最后一行,就像用户指南中所说的那样,以显示如何附加缓冲区。 – Roel 2015-04-02 13:55:20
这很好,但在将来它可以帮助您显示实际使用/尝试的代码而不是文档示例。 – Samutz 2015-04-02 14:08:20