View loses the path as the case of the controller call |
Hi All!
I'm using the controller: PHP Code: public function test() { to call the view-page "messages_view.php", which shows a picture: Code: <!DOCTYPE html> By sending: http://localhost/testproject/index.php/employee/test/ It works fine! But if I have transfer parameters like: PHP Code: public function test($var1, $var2) { By sending: http://localhost/testproject/index.php/e...e/test/1/2 the messages_view.php loses the path to the picture! It seems that the deep of the path depends on the amount of the called transfer parameters. How could I resolve this situation?
Don't use a relative path, with "../.." stuff. That means it's looking down from the 2 dirs from the CURRENT url, so if you have more parameters in the url it looks in the wrong location!
Load the url helper (autoload) and use base_url(), like: PHP Code: <img src="<?php echo base_url('image/app/mypic.jpg'); ?>" /> will produce http://yoursite.com/image/app/mypic.jpg for the image src |
Welcome Guest, Not a member yet? Register Sign In |