0

I've built a function on class Image that retrieves or should retrieve me the image in a binary format. However I just get the error icon when I call that controller method.

I need this done this way, because the images are being sent to an iOS and Android app.

The path of the image is correct (I've double checked it)

I'm using CodeIgniter 2.1.3 and my code looks like this

$images = $this->image->getImageById($database,$id);

        $data = fopen($images->path, 'rb');
        header('Content-type: image/jpeg');
        fpassthru($data);

Any idea on how can I achieve this?

Thank you

João Dias
  • 1,078
  • 1
  • 15
  • 38

2 Answers2

0

I thing you are looking for something like this.

http://www.ehow.com/how_8745742_convert-binary-data-using-php.html

Arun
  • 685
  • 5
  • 20
-2

I think this may help you. After getting the result in your model file in an array. In your example $images.

In the view file display it like this <img src="<?php echo $images['path'] ?>" />

Venkata Krishna
  • 4,287
  • 6
  • 30
  • 53
  • I don't want to display an image. I want to send it as a binary – João Dias Nov 20 '12 at 12:09
  • In the first line - "I've built a function on class Image that retrieves or should retrieve me the image in a binary format." I don't want to send the image link. I want to send the whole image! – João Dias Nov 20 '12 at 12:15