Codeigniter 此处图像已在数据库中更新,但未在目录中更新
此处为控制器页面,此处为图像名称插入到数据库中,但图像未进入相应的目录Codeigniter 此处图像已在数据库中更新,但未在目录中更新,codeigniter,Codeigniter,此处为控制器页面,此处为图像名称插入到数据库中,但图像未进入相应的目录 if(isset($_POST['submit'])) { $config['upload_path'] = './upload/'; $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|mp4'; $this->load->library('upload', $config);
if(isset($_POST['submit']))
{
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|mp4';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$data = array
(
'student_name' => $this->input->post('dname'),
'student_email' => $this->input->post('demail'),
'student_mobile' => $this->input->post('dmobile'),
'student_address' => $this->input->post('daddress'),
'picture' => $_FILES['picture']['name']
);
}
$insertuserdata=$this->Inserts_model->form_insert($data);
此处查看页面
<form action="<?php echo site_url('Insert_ctrl/index/'); ?>"
method="post" enctype="multipart/form-data">
<label>NAME</label>
<input type="text" name="dname" required onkeyup="textt(this)"
id="name"><br>
<label>email</label>
<label>Picture</label>
<input class="form-control" type="file" name="picture" /><br>
<input type="submit" name="submit" value ="submit">
</form>
您应该这样尝试
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|mp4';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if(!$this->upload->do_upload('picture'))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else{
$data = array('upload_data' => $this->upload->data());
print_r($data);
}
删除$this->upload->initialize($config)代码>行。如果在装入类时传递第二个参数,您不需要使用配置数组初始化类。@Tpojka因此在上载目录中没有filgets您没有使用上载函数,但希望上载文件?我没有使用do\u uploadfunction@jibinkj然后您需要使用@Mayank Vadiya,因此没有输出确保您上传的目录有适当的权限