1

i want to add a banner image .

 <div class="slide" style="background-image: url('Style/images/banner/banner.jpg');">

how can i use this in CodeIgniter file

i tried

<div class="slide" style="background-image: url('<?php echo base_url()?>/Style/images/banner/banner.jpg');">
4
  • seems right to me.. but the paths are different.. check what does base_url() gives you.. to debug just copy the url produce and paste it on your browser.. I think it's 404 coz the first snippet is relative and in codeigniter is absolute, so better check your image directory Commented Dec 1, 2015 at 7:27
  • make sure Style S is caps in folder name Commented Dec 1, 2015 at 7:29
  • Yes . S is caps :( Commented Dec 1, 2015 at 7:31
  • can you add folder structure?? Commented Dec 1, 2015 at 8:13

3 Answers 3

3

Try using

style="background-image: url('<?php echo base_url('Style/images/banner/banner.jpg') ?>')"

Sign up to request clarification or add additional context in comments.

Comments

1

You can just do like this. No need to use base_url()

<div class="slide" 
style="background-image: url('Style/images/banner/banner.jpg');">

Make sure your folder call Style's first letter is capitalized.


EDIT 01

Provide permeation to image

goto project root
cd Style/images/banner/
sudo ^Cmod -R 777 banner.jpg

3 Comments

check image permition
@AbySebastian did you check this??
not that OC but just want to correct permition should be permission
1

You can use internal css in view file, check below example.

<style>
.slide{
  background-image: url('<?php echo base_url()>/Style/images/banner/banner.jpg');
}
</style>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.