Php Codeigniter映像路径未存储在数据库中

Php Codeigniter映像路径未存储在数据库中,php,codeigniter,file-upload,Php,Codeigniter,File Upload,嗨,朋友们,这是我在这里的第一个问题,我希望能让你们明白我想要什么,因为我是codeigniter的新手,英语也不好:p 所以我的问题是我试图上传图像使用Codeigniter我有两个文件夹 1.1完整图像 2.对于thumnils图像 但当我上传时,它会给我错误信息 列“img_path”不能为null 这是我的控制器模型和视图 控制器: ` ` 模型 ` 看法 我努力解决这个问题,也让你们明白我的问题是什么 上传代码应移到控制器。模型仅用于数据库 这是错误的输入 $new_image_ins

嗨,朋友们,这是我在这里的第一个问题,我希望能让你们明白我想要什么,因为我是codeigniter的新手,英语也不好:p

所以我的问题是我试图上传图像使用Codeigniter我有两个文件夹 1.1完整图像 2.对于thumnils图像 但当我上传时,它会给我错误信息

列“img_path”不能为null

这是我的控制器模型和视图

控制器:

`

`

模型 `

看法

我努力解决这个问题,也让你们明白我的问题是什么

上传代码应移到控制器。模型仅用于数据库 这是错误的输入

$new_image_insert_data = array(
   'img_path' => $this->input->post('userfile'), # Wrong
   'img_name' => $this->input->post('img_name')
);
应添加此$this->gallery\u路径

所以在db上,记录将是

img_path -->../images'   
img_name --> xyz.jpg

在表单中,输入字段如下

 <input type="file" id="userfle" name="userfle" required class="md-input" />
img_路径应该是您的文件夹路径

$new_image_insert_data = array(
        'img_path' => $this->gallery_path_url,
        'img_name' => $this->input->post('img_name') /** if you don't want to change uploaded image file name**/
        );

你走错了路

    $new_image_insert_data = array(
    'img_path' => $this->input->post('userfile'),
    'img_name' => $this->input->post('img_name')
    );
文件输入不能得到这样的结果

上传文件后,您将获得上传文件的所有数据 所以你可以这样储存

$new_image_insert_data = array(
        'img_path' => $image_data['file_path'],
        'img_name' => $image_data['file_name']
        );

看到这个了吗

他根本无法访问模型的post输入,是吗?看起来他在模型中的大部分代码应该移到控制器开始。谢谢你,伙计。你解决了我的问题:@TariqAli,如果这有帮助的话。因此,谢谢你朋友的帮助谢谢你的帮助,朋友,你救了我一天
$new_image_insert_data = array(
   'img_path' => $image_data['file_path'],
   'img_name' => $image_data['file_name']
);
img_path -->../images'   
img_name --> xyz.jpg
 <input type="file" id="userfle" name="userfle" required class="md-input" />
<input type="file" id="userfle" name="userfile" required class="md-input" />
 $new_image_insert_data = array(
        'img_path' => $this->input->post('userfile'),
        'img_name' => $this->input->post('img_name')
        );
$new_image_insert_data = array(
        'img_path' => $this->gallery_path_url,
        'img_name' => $this->input->post('img_name') /** if you don't want to change uploaded image file name**/
        );
    $new_image_insert_data = array(
    'img_path' => $this->input->post('userfile'),
    'img_name' => $this->input->post('img_name')
    );
$new_image_insert_data = array(
        'img_path' => $image_data['file_path'],
        'img_name' => $image_data['file_name']
        );