Cannot display images in CodeIgniter |
Hi. I just cannot display an image in CodeIgniter. I am constantly getting 404 response from the server and the image is not displayed:
Code: <?= $this->extend('layouts/default') ?>
root
-- public or public_html ---- index.php ---- assets ------ css ------ js ------ images ------ img ------ plugins ------ vendor then you can access them like this Code: <img src="<?= base_url('assets/images/profile.jpg');?>"> What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Use developer tools (F12) to find the exact location of the image which is not being displayed.
Check that against your code and location of the image in you CI installation.
Tried that. They are identical. http://localhost:8080/project-root/asset...rofile.jpg
And if you open
http://localhost:8080/project-root/public/assets/images/profile.jpg In your browser? What is your folder structure Where is the app and public folder located?
I am getting "Can't find a route for 'get: project-root/public/assets/images/profile.jpg'". Folder structure is the following: I have project-root folder, which is the baseUrl. Directly inside that folder is the assets folder with images folder in it. I am trying to access the image from index.php file, which is located in Views folder.
Did you try InsiteFX suggestion to create an assets folder in the public folder, then add an image folder in assets folder? If only to test if that works.
Yes I did that exactly - otherwise path would be wrong. But it did not work out. Maybe I should create separate route for the picture? I am a little bit new to CodeIgniter. Excuses in advance
You should put your images in the public folder.
Code: root |
Welcome Guest, Not a member yet? Register Sign In |