Display PNG img in view not working |
Hi,
I put a PNG image in my public/images folder. I created a view like below but it doesn't show me my image : Code: <!DOCTYPE html> What it means ?
is this working (add slash at beginning, read as from based url)
Code: <img src="/images/download.png"/>
play along the lines of
<img src = "<?php echo base_url('images/download/download.png'); ?>" > in a view the path above should be inside public images->download->download.png so ypu shouldn't need to quote public a quick tips is when viewing web page and iimage not showing , go to "view source" in browser and see what the actual path that is being quoted in view source and if it makes sense
It's always best to use the base_url with images, because if you change to a new server it will still find them.
root -- public ---- assets ------ images --> ( base_url('assets/images/image.png'); ) ------ etc; -- app -- modules -- system -- writable What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
My code below :
Code: <!DOCTYPE html> The second one works.
i think its do to with controllers and the way data is passed to a view.
So to use base_url() in a view from memory you have to use url helper ; i tend not to remember because what i've done is declare them in the base controller so that they are there in any subsequent controller that extends from the base controller. Now its no problem echoing out a constant in a controller, but in a view , i guess that would have to be passed, in an appropriate way . |
Welcome Guest, Not a member yet? Register Sign In |