php - display image from database in codeigniter -


good day! trying retrieve image path name stored database struggling display image folder , i'll explain later... here code.

in controller

public function save() {     $url = $this->do_upload();     $title = $_post["title"];     $this->main_m->save($title, $url); }  public function do_upload() {     $type = explode('.', $_files["pic"] ["name"]);     $type = $type[count($type)-1];     $url = "./images/".uniqid(rand()).'.'.$type;     if(in_array($type, array("jpg","jpeg","gif","png")))     if(is_uploaded_file($_files["pic"]["tmp_name"]))         if (move_uploaded_file($_files["pic"]["tmp_name"], $url))     return $url; } 

in view im trying retrieve this.

 <?php foreach ($this->b->getalldata() $row) {       echo '<li>'.                 '<a class="ns-img" href="'.base_url("images/".$row->image).'".></a>'.                 '<div class="caption">'.$row->title.'</div>'.           '</li>';               } ?> 

in model

public function save($title, $url) {     $this->db->set('title', $title);     $this->db->set('image', $url);     $this->db->insert('slider'); } 

the image stored path folder , new name of image stored database displaying image not working me. image path folder "images" , image name stored database "./images/new_name.jpg" not same name image stored folder path. image name stored folder path has no ./images/ new_name.jpg...

how display image? tried that? help!

you need explode image name "./images/new_name.jpg".

$image_arr = explode("/", "./images/new_name.jpg");  echo $image_name = end($image_arr); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -