在Codeigniter中从http post请求获取附件


Getting attachments from http post request in Codeigniter

我使用Mailgun来接收使用Codeigniter开发的web应用程序的电子邮件。Mailgun为每封收到的电子邮件发送一个http post到以下(http://something.com/email) url。

我用下面的代码得到电子邮件的内容。

function email_to_db(){
   $email_body = $this->input->post('body-plain', '');
   $email_sender = $this->input->post('sender');
}

但是我无法获取附件。
有人能指导我如何才能做到这一点吗?以下是我的参考文档的链接

附件是文件,你应该使用文件上传类

$config = [];
$config['upload_path']          = './uploads/';
$config['allowed_types']        = 'gif|jpg|png';
$config['max_size']             = 100;
$config['max_width']            = 1024;
$config['max_height']           = 768;
$this->load->library('upload', $config);
if (!$this->upload->do_upload())
{
    $error = array('error' => $this->upload->display_errors());
}
else
{
    $data = array('upload_data' => $this->upload->data());
}

您也可以执行print_r($_FILES);并检查附件文件