简体   繁体   中英

Store image path in 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']);

Yes. 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. Because in your server there is no partition call C: .

So use your path as it is.

Edit

<?php

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

    echo $fulpath;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM