0
在显示我的图像从数据库中获取它是好的,但我想显示默认图像,如果没有用户还没有上传照片。我救了一个没有avatar.jpg我/上传文件夹如果用户没有照片codeigniter显示默认图像
这里是我的显示用户图像。
视图
<img height="180px" width="180px"class="ppborder" src="<?php echo base_url().'/uploads/'.$this->session->userdata('image'); ?>">
上传
public function updatephoto($id)
{
if ((int)$id < 1)//$id is not an integer
{
redirect('Memberlogincontroller/member_view', 'refresh');
}
else{
$this->load->helper(array('form','file','url'));
$this->load->library('form_validation');
$config_image = array(
'upload_path' => './uploads/',
'allowed_types' => 'gif|jpg|png',
'max_size' => '1024',
'overwrite' => true
);
$this->load->library('upload', $config_image);
if($this->form_validation->run()==false and empty($_FILES['userfile']['name'][0]))
{
$id = $this->session->userdata('id');
$memberinfo = array(
'error_image' => ''
);
$this->session->set_flashdata('flashError', 'Oops no photo selected', $memberinfo);
redirect('index.php/Memberlogincontroller/editphoto/'.$id, 'refresh');
}
else
{
$this->upload->do_upload();
$data = array('upload_data' => $this->upload->data());
$this->image_resize($data['upload_data']['full_path'], $data['upload_data']['file_name']);
$id = $this->session->userdata('id');
$this->db->where('id', $id);
$query = $this->db->get('member');
$data = array(
'image' => $data['upload_data']['file_name']
);
$this->db->update('member',$data,array('id'=>$id));
$this->session->set_userdata($data);
$this->session->set_flashdata('flashSuccess', 'Your photo has been updated.');
redirect('index.php/Memberlogincontroller/getMember/'.$id, 'refresh');
}
}
}
如何显示我的默认图像?
非常感谢。我明白了:D – secrenymous
**在这笔钱上......有一些比这更冗长的东西,完全没有工作。谢谢...** – HomeOffice