在codeigniter中存储图像路径

q3aa0525  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(146)

你好,我写了一个代码,上传图像路径到数据库,但事情是它上传的真实的路径(C:/wamp/www/amref/images/student_profile/childbrah2.jpg)因此,当我从数据库中获取路径,以显示图像,它给我的错误,链接是断开的。我只想存储(images/student_profile/childbrah2.jpg)。

控制器代码:

$config['upload_path'] = '../images/student_profile/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg';
        $config['max_size'] = "2048000"; // Can be set to particular file size , here it is 2 MB(2048 Kb)
        $config['max_height'] = "768";
        $config['max_width'] ="1024";

        $this->load->library('upload', $config);

        if(!$this->upload->do_upload()){

             echo '<h4 style="color: red;">

                    Failure! </h4>

                    <p style="color: red;">'.$this->upload->display_errors().'</p>';


        } else {
            $data_upload_files = $this->upload->data();

            $image = base_url($data_upload_files['full_path']);
x4shl7ld

x4shl7ld1#

是的。因为你插入了$config['upload_path'] = '../images/student_profile/',所以路径是C:/wamp/www/amref/images/student_profile/
如果您输入C:/wamp/www/amref/images/student_profile/,这在您的服务器上将不起作用。因为在您的服务器上没有分区,请调用C:
所以,用你的道路,因为它是。

编辑

<?php

    $old = 'C:/wamp/www/amref';
    $fulpath = $old.'/images/student_profile/';

    echo $fulpath;

相关问题