Jump to content

Recommended Posts

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');

     }

}

 

Link to comment
https://forums.phpfreaks.com/topic/238617-codeigniter-image-loader/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.