如何在 codeigniter 中附加文件

How to attach a file in codeigniter

如何在 Codeigniter 邮件中附加文件 class?

 <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() 中要提供什么。

您必须在附加函数中输入附件的路径,例如 $this->email->attach('/path/to/attachment');

如果您想添加多个文件,请重复同一行。

注意路径不应该是URL.

您可以在 codeigniter email sending with codeIgniter

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

$this->email->send();

使用这个:-

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

Click On This link for Full details about email function