[英]Unable to Store image path into database using codeigniter - Student Registration
I am working on a school management system. 我正在研究学校管理系统。 I am storing student information with their image.
我正在用他们的图像存储学生信息。 I am using this code so my all information is update in data base but image path is not getting in the database.
我正在使用此代码,因此我的所有信息都在数据库中更新,但是图像路径未进入数据库。 I am unable to find the error.
我找不到错误。 please help me.
请帮我。 I have already load the upload library.
我已经加载了上传库。 I want to store student information to data base.
我想将学生信息存储到数据库中。 I want to store student image in to upload folder.
我想将学生图像存储在要上传的文件夹中。
my directory structure is 我的目录结构是
My controller code is 我的控制器代码是
public function saveStudent() {
$data = array();
$config = array(
'upload_path' => '/upload/',
'allowed_types' => 'gif|jpg|png|jpeg',
);
$this->load->library('upload', $config);
if ($this->upload->do_upload('photo')) {
$fileName = $this->upload->data();
$image = $fileName['file_path'];
$data = array(
'student_name' => $this->input->post('name'),
'class' => $this->input->post('class'),
'section' => $this->input->post('section'),
'addressline1' => $this->input->post('addressline1'),
'addressline2' => $this->input->post('addressline2'),
'city' => $this->input->post('city'),
'mobile' => $this->input->post('mobile'),
'gender' => $this->input->post('gender'),
'dob' => $this->input->post('dob'),
'religion' => $this->input->post('religion'),
'category' => $this->input->post('category'),
'addmission_date' => $this->input->post('adddate'),
'registrationdate' => $this->input->post('registration'),
'fathername' => $this->input->post('fathername'),
'foccu' => $this->input->post('foccu'),
'fquali' => $this->input->post('fquali'),
'fmobile' => $this->input->post('fmobile'),
'fdob' => $this->input->post('fdob'),
'mothername' => $this->input->post('mothername'),
'moccu' => $this->input->post('moccu'),
'mquali' => $this->input->post('mquali'),
'mmobile' => $this->input->post('mmobile'),
'mdob' => $this->input->post('mdob'),
'lastschool' => $this->input->post('lastschool'),
'lastexam' => $this->input->post('lastexam'),
'lastresult' => $this->input->post('lastresult'),
'lastmark' => $this->input->post('lastmark'),
'board' => $this->input->post('board'),
'adharcard' => $this->input->post('adharcard'),
'TC' => $this->input->post('TC'),
'CC' => $this->input->post('CC'),
'result' => $this->input->post('result'),
'dobc' => $this->input->post('dobc'),
'user_id' => $this->session->userdata('user_id'),
'photo' => $image // add this for image
);
}
$this->db->insert('student', $data);
}
please help me i want to upload image to upload folder and store path to database. 请帮我,我想上传图片到上传文件夹并存储到数据库的路径。
Just try this method when the upload success 上传成功后只需尝试此方法
$path = $this->upload->data('full_path');
To debug the name just die from here and check die($path)
要调试名称,只需从此处死亡,然后检查
die($path)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.