如何在codeigniter中附加文件

时间:2015-03-11 05:06:27

标签: php codeigniter

如何在Codeigniter电子邮件类中附加文件?

 <input type="file" class="default" name="attach">

在我的控制器中:

$this->load->library('email');
                $this->email->set_mailtype("html");
                $this->email->set_newline("\r\n");
                $this->email->from('admin@admin.com'); 
                $this->email->to($emailid);// change it to yours
                $this->email->subject($subject);
                $this->email->message($message);
                $this->email->attach();
                $this->email->send();

我不知道在attach()中要提供什么。

3 个答案:

答案 0 :(得分:0)

您必须在$this->email->attach('/path/to/attachment');

等附加功能中输入附件的PATH

如果你想添加多个文件,请重复相同的行。

请注意,路径不应为网址。

答案 1 :(得分:0)

您可以在codeigniter email sending with codeIgniter

中关注此网址以获取电子邮件参考
$this->email->attach('/path/to/photo1.jpg');
$this->email->attach('/path/to/photo2.jpg');
$this->email->attach('/path/to/photo3.jpg');

$this->email->send();

答案 2 :(得分:0)

使用此: -

$this->email->attach('/path/to/photo1.jpg');

Click On This link for Full details about email function