Php 为什么不能在电子邮件中显示图像,我使用了codeigniter

Php 为什么不能在电子邮件中显示图像,我使用了codeigniter,php,codeigniter,Php,Codeigniter,控制器 public function index() { $config['upload_path'] = './uploads/volunteer'; $config['allowed_types'] = 'gif|jpg|png'; $this->load->library('upload', $config); if (!$this->upload->do_upload('userfile'

控制器

public function index() {

$config['upload_path'] = './uploads/volunteer';
            $config['allowed_types'] = 'gif|jpg|png';
            $this->load->library('upload', $config);
            if (!$this->upload->do_upload('userfile')) {
                $error = array('error' => $this->upload->display_errors());
                var_dump($error);
            } else {
                $data = $this->upload->data();
                send_mail('New Volunteer Form received', $this->load->view('site/email/volunteer', $data, TRUE));
            }
}
}
辅助功能

function send_mail($subject, $message) {

    /* @var $CI CI_Controller  */
    $CI = &get_instance();
    $CI->load->library('upload');
    $CI->load->library('email');
    $CI->email->from('noreplay@xxx.com', 'Hello');
    $CI->email->to('xxx@xxx.com');
    $CI->email->subject($subject);
    $CI->email->message($message);
    $CI->email->set_mailtype('html');

    return $CI->email->send();
}
查看

下表显示电子邮件中的图像

<table>
       <tr>
         <td>Photo</td>
        <td style="text-align: center"><img src="<?php base_url() ?>uploads/volunteer/<?php echo $file_name; ?>" height="100" width="150"></td>
                                </tr>
</table>

照片
上传/志愿者/“height=“100”width=“150”>

我的问题:为什么不能在我的电子邮件中显示图像,我使用了codeigniter

我的英语不是很好,请你看看


也许当你使用

你可以这样写:

你应该使用“echo”的Url,然后它就会显示出来

另外,我不知道在“uploads/volunterr/”之前是否应该使用/Symbol

您可以查看电子邮件并使用firebug或chrome控制台检查src是否正确。

您可以尝试以下方法:

<table>
       <tr>
         <td>Photo</td>
        <td style="text-align: center"><img src="<?php echo base_url() ?>uploads/volunteer/<?php echo $file_name; ?>" height="100" width="150"></td>
                                </tr>
</table>

照片
上传/志愿者/“height=“100”width=“150”>
但是请检查您是否在config文件/application/config/config.php中配置了一些内容,例如

$config['base_url']=''