Call Image Path From Database |
[eluser]rochellecanale[/eluser]
hello guys. How can i call the image from my upload folder? Here's my path in upload folder. Code: C:\xampp\htdocs\eMLM\uploads Here's the path with image Code: C:\xampp\htdocs\eMLM\uploads\Sunset.jpg I putted the path in the database like this Code: http://localhost/eMLM/upload/Sunset.jpg 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: Code: $this->db->select('file_path'); But nothing shows.
[eluser]surf66[/eluser]
Hi, on my application I just save the image name to the db and I show the image in my view like this: Code: <img src="<?php echo base_url('uploads/' . $image_thumb); ?>" /> 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: Code: <img src="<?php echo $path; ?>" alt="Your alt text" /> I hope this can help in any way
[eluser]CroNiX[/eluser]
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: http://localhost/eMLM/upload/Sunset.jpg Do you see your image?
[eluser]rochellecanale[/eluser]
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.
[eluser]rochellecanale[/eluser]
Ok thanks What i did is replace the code with this Code: <img src="<?php echo base_url('uploads/' . $image_thumb); ?>" /> Thanks again.
[eluser]boltsabre[/eluser]
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: Code: <img src="<?php echo $IMG_PATH.$image_thumb); ?>" /> 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="..." |
Welcome Guest, Not a member yet? Register Sign In |