ShoeLace1291 Posted June 7, 2011 Share Posted June 7, 2011 I'm trying to extend the codeigniter loader class with a function that outputs an image based on content provided through a parameter. When I try to view the file, i get the following error: The image “http://localhost/lensereflex/main.php/images/test” cannot be displayed because it contains errors. This is my loader class: <?php class MY_Loader extends CI_Loader { function dynamic_image($content = '', $type = 'jpeg', $file_name = FALSE){ if($content == ''){ show_error('There is no output to display.'); return FALSE; } else { header('Content-Length: '.strlen($content)); header('Content-Type: image/'.$type); if($file_name == TRUE){ header('Content-Disposition: inline; filename="'.basename($file_name).'";'); } return $content; } } } This is how I call the function: <?php class Images extends CI_Controller { function test(){ $this->load->dynamic_image('Image Test', 'jpeg', 'test.jpg'); } } Quote Link to comment https://forums.phpfreaks.com/topic/238617-codeigniter-image-loader/ Share on other sites More sharing options...
monkeytooth Posted June 13, 2011 Share Posted June 13, 2011 did you reconfigure your routes.php in the config folder in the routes php to support "main.php" instead of "index.php"? Also what your attempting to do may better be served as a module that you load into a controller.. instead of the extension concept. Quote Link to comment https://forums.phpfreaks.com/topic/238617-codeigniter-image-loader/#findComment-1228963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.