Kakshak Kakshak - 1 month ago 7
PHP Question

How to add an image in codeigniter

I m learing codeigniter and i want to add an image in my view page.
I am using tag but the image is not added in the page.
So help me how i can add the image in view page of codigniter.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Blog</title>
</head>

<body>
<h2><img src="../images/logo.png"></h2>
<?php $this->load->view('blog/menu');
if ($query):foreach ($query as $post): ?>
<h4><?php echo $post->entry_name; ?> (<?php echo $post->entry_date; ?>)</h4>
<?php echo $post->entry_body; ?>
<?php endforeach;
else: ?>
<h4>No entry yet!</h4>
<?php endif; ?>
</body>
</html>

Answer

store images in an images folder at the same level as the application folder . then just link to it like this using code.

<img src="<?php echo base_url('images/logo.png'); ?>" />
Comments