douduiwei2831 2015-07-09 07:59
浏览 73

在codeigniter中存储图像路径

Hello I have a write a code that upload image path into the database but the thing is it uploads the real path (C:/wamp/www/amref/images/student_profile/childbrah2.jpg) hence when I fetch the path form the database in order to display the image it gives me the error that the link is broken. I want to store only (images/student_profile/childbrah2.jpg).

The controller code:

$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']);
  • 写回答

1条回答 默认 最新

  • dsdapobp26141 2015-07-09 08:04
    关注

    Yes of course. It want be happen.

    Because you inserting $config['upload_path'] = '../images/student_profile/';

    so path is C:/wamp/www/amref/images/student_profile/.

    If you enter this as C:/wamp/www/amref/images/student_profile/ this will not work in your server. Cz in your server there is no partition call C:.

    So use your path as it is.

    EDIT 01

    <?php
    
        $old = 'C:/wamp/www/amref';
        $fulpath = $old.'/images/student_profile/';
    
        echo $fulpath;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染