1
在我的頁面中,我創建了一個具有不同字段(如名稱,電子郵件,密碼等)的表單,現在我必須上傳圖像並存儲在我的數據庫中。任何人都會發送包含圖片上傳文件在內的所有字段的代碼。我必須多次嘗試,圖像無法在我的數據庫中上傳。 我的控制器是代碼igniter-如何將圖像保存在我的數據庫中mysql/php
function activity()
{
$this->load->library('form_validation');
//field name,error message, validation rules
$this->form_validation->set_rules('activityid', 'Activity Id', 'trim|required');
$this->form_validation->set_rules('hostid', 'Host Id', 'trim|required');
$this->form_validation->set_rules('activityname', 'Activity Name', 'trim|required');
$this->form_validation->set_rules('date', 'Date', 'trim|required');
$this->form_validation->set_rules('venue', 'Venue', 'trim|required');
$this->form_validation->set_rules('typeofactivity', 'Type of Activity', 'trim|required');
$this->form_validation->set_rules('conductedby', 'Conducted By', 'trim|required');
$config['upload_path'] = './asset/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$w = $this->upload->data();
if($this->form_validation->run()==FALSE)
{
//$this->load->view('signup_form');
$this->activity_reg();
}
else
{
$this->load->model('membership_model');
$query=$this->membership_model->activity();
if($query)
{
$data['main_content']='signup_successful';
$this->load->view('includes/templates',$data);
}
else
{
$this->load->view('activity');
}
}
}
我的模型是
function activity()
{
$w = $this->upload->data();
$new_member_insert_data= array(
'activityid'=>$this->input->post('activityid'),
'hostid'=>$this->input->post('hostid'),
'activityname'=>$this->input->post('activityname'),
'date'=>$this->input->post('date'),
'venue'=>$this->input->post('venue'),
'typeofactivity'=>$this->input->post('typeofactivity'),
'conductedby'=>$this->input->post('conductedby'),
'image' => $w['file_name']
);
$this->load->database();
$insert=$this->db->insert('activity',$new_member_insert_data);
return $insert;
}
從圖像上傳庫中獲取的錯誤是什麼? –
沒有error.data的只存儲在我的數據庫中,不存儲在圖像 – abu
你想存儲圖像或圖像名稱嗎? –