Codeigniter 4 installation and img directory |
I have installed Codeigniter 4 in the xampp c:\xampp\htdocs\
I have added a virtual host in the httpd-vhosts under C:\xampp\apache\conf\extra I have also added 127.0.0.1 kpi.local in the etc/host Code: <VirtualHost *:80> My codeigniter4 project name is kpi. everything is working fine and my project is running absolutely fine as http://kpi.local but i have img folder in my public directory and base url in config is defined as http://kpi.local but when i check the html source code it is shown as http://kpi.local/public/img/logo.png. but unfortunately logo.png does not appear in the page and img directory doesn't seems to be accessible to my project and when i click on the above link it says 404 file not found. Kindly help me how can allow images to be perfectly displayed in my project. Thanks
It should work. Do you use base_url() to generate the image’s url?
I’d say, double-check your config files (CI and virtual host) and your view files, and restart your web server.
This is how my Virtual Host is setup, change public_htnl to public.
Code: #-------------------------------------------------------------- I create an assets folder under the public folder and use the base_url to access it; Code: <img src="<?= base_url('assets/images/someimage.png');?>" alt="Smiley face"> Give that a try. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@itrashulk
> shown as http://kpi.local/public/img/logo.png. but unfortunately logo.png does not appear in the page and img directory doesn't seems to be accessible to my project and when i click on the above link it says 404 file not found. A couple of points to check: 1. usually online server is Apache2 and filenames, directories, etc are CaSeSenSitive. 2. rendering the page and browsing/viewing the content (right-click, view content) will show the full path of the image. Copy the full path and paste into a new browser window. This should show the image unless the directory and image are read only.
|
Welcome Guest, Not a member yet? Register Sign In |