user3551487
user3551487

Reputation: 162

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']);

Upvotes: 0

Views: 1388

Answers (1)

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

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;

Upvotes: 1

Related Questions