• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Call Image Path From Database

hello guys. How can i call the image from my upload folder?

Here's my path in upload folder.

Here's the path with image

I putted the path in the database like this
using the file_path

But it does not shows any image. It shows an image icon and a border the icon looks like a tear paper. How can i call the image from my folder? Please help me guys.

I try to pull out the info from my database like this:

$query = $this->db->get_where('upload',array('username'=>'andromeda009'));
$row = $query->row();
$path = $row->file_path;

echo "<img src='{$path}' width='100' height='100' />";

But nothing shows.

Hi, on my application I just save the image name to the db and I show the image in my view like this:

<img src="&lt;?php echo base_url('uploads/' . $image_thumb); ?&gt;" />

Also when your echoing the var $path I don't think you should have the curly braces there if it was me I would try this:

<img src="&lt;?php echo $path; ?&gt;" alt="Your alt text" />

I hope this can help in any way

What does your html look like for that img tag once the page is rendered? When you see the image missing icon, do a view source and post the HTML for that img. Whatever path is there for the src should give you an indication of what's going wrong.

Also, if you go to:

Do you see your image?

No it displays page not found. So i can't call the image directly? Hmm.. Ok thanks. I will do your advice. Hope it works.

Ok thanks
What i did is replace the code with this

<img src="&lt;?php echo base_url('uploads/' . $image_thumb); ?&gt;" />

Thanks again.

To save a little time coding, I created a few site wide variables, ($IMG_PATH, $CSS_PATH, and $JS_PATH), in my MY_Controller (but you could do it in your config file or whatever suits you best).

Then you can just do this:
<img src="&lt;?php echo $IMG_PATH.$image_thumb); ?&gt;" />

It has the advantages that if you every change your directory structure (ie, you move your images from "uploads" to a new folder called "public/images") all you have to do is change $IMG_PATH and everything else will still work! With your current set-up, if you ever change your directory structure you will have to go and change EVERY image src="..."

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.