【发布时间】:2015-09-30 11:54:30
【问题描述】:
我尝试搜索但没有成功我想将最多 5 张图片与用户表单数据一起上传到数据库。我有一张表格,其中所有已发布表单的用户数据与上传的图片一起保存[图片上传附有用户表单]图片数据库中的字段被命名为 pic1,pic2,pic3.. pic5 + 电子邮件,密码等我成功地将图像数据上传到数据库,但不是图像。
//控制器
if ($this->form_validation->run()!=true) {
$data['countryDrop'] = $this->Country_states_cities->getCountries();
$this->load->view('header');
$this->load->view('register',$data); //Display page
$this->load->view('footer');
}else{
$form=array();
$form['first_name']=$this->input->post("first_name",true);
$form['last_name']=$this->input->post("last_name",true);
$form['dob']=date('Y-m-d',strtotime($this->input->post("dob",true)));
$form['email']=$this->input->post("email",true);
$form['password']=sha1($this->input->post("password",true));
$form['phone']=$this->input->post("phone",true);
$form['addline2']=$this->input->post("addressline2",true);
$form['zip']=$this->input->post("zip",true);
$result = $this->Couch_reg->insert_new_user($form); //call to model
//模型
function insert_new_user($form)
{
$this->db->insert('tbl_usrs',$form);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
//查看
<input type="file" name="uploadfile[]" accept = "image/*" multiple = "multiple" size="20" /> <br />
我们可以看到模型部分很短,我想以数组形式收集图像名称并将其发送到数据库。
【问题讨论】:
-
@wolfgang1983 是的,但我想上传“多张图片”并将其保存到数据库
标签: mysql image codeigniter