小编ign*_*ash的帖子

Codeigniter:如何获取文件的文件名

我是一个Codeigniter新手,我试图获取上传图像的文件名,以便我可以将其保存在数据库中.我有两个模型,homemodel处理我的数据库和image_upload_model处理图像上传.一切正常,但我不知道如何将图像文件名发布到数据库

image_upload_model.php

<?php

class Image_upload_model extends CI_Model {

    var $image_path;

    //constructor containing the image path
    function Image_upload_model() {

        $this->image_path = realpath(APPPATH.'../assets/img');
    }

    //uploading the file
    function do_upload() {

        $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->image_path
        );
        $this->load->library('upload',$config);
        $this->upload->do_upload();
    }
}
?>
Run Code Online (Sandbox Code Playgroud)

homemodel.php

<?php

class homeModel extends CI_Model {

    //inserting into the table tenants
    function addTenants() {

        $this->load->model('Image_upload_model');

        $data = array(
            'Fname' => $this->input->post('Fname'),
            'Lname' => $this->input->post('Lname'),
            'contact' => $this->input->post('contact'),
            'email' => $this->input->post('email'),
            'location' => $this->input->post('location'),
            'img_url' => " …
Run Code Online (Sandbox Code Playgroud)

php codeigniter

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

codeigniter ×1

php ×1