我有程序上传图片并显示上传结果。但是当我显示图像时只显示路径图像而不是图像。在数据库中,我通过full_path保存。请告诉我代码如何从我的代码中显示图像。
这是控制器:
function do_upload()
{
$config['upload_path'] = './images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100000';
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($this->upload->data());
$datafoto=$this->upload->data();
$nm_file = time().$datafoto['full_path'];
$this->load->model('mkegiatan');
$this->mkegiatan->update_foto($nm_file);
copy('images/'.$datafoto['full_path'], 'images/'.$nm_file);
}
}
以下是观点:
<?php echo e($kegiatan->image) ; ?>
答案 0 :(得分:1)
所以你说你只看到图像路径而不是图像本身?尝试替换它:
<?php echo e($kegiatan->image) ; ?>
有了这个:
<img src="/<?php echo e($kegiatan->image) ; ?>" />