我正在做一个脚本,将上传图像并保存图像路径在数据库中。我唯一的问题是如果用户没有上传图像,我想设置默认图像。设置默认图像,如果没有图像被选中上载在codeigniter
但在codeigniter中,当图像未被选中时,它会自动给出一个错误,说明没有选择输入文件。
我控制器
if (!$this->upload->do_upload('image'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_success', $error);
}
else {
$image_data=array('image_info' => $this->upload->data('image'));
$image_path=$image_data['image_info']['full_path'];
$data =array(
'submitedby'=>$username,
'city'=>$this->input->post('towncity'),
'image' => $image_path
);
}
可有人请建议我如何,如果用户没有显示默认的错误选择的图像设置一个默认的形象?