Welcome Guest, Not a member yet? Register   Sign In
Serving Image from controller (warning newbie alert)
#1

[eluser]MattEth[/eluser]
Hi guys,

I'm very new to PHP and CI (I'm a java programmer), so please be patient Smile

I am attempting to load an image (via http from another site - this will eventually just be from a database), then I want to serve the image from the controller so that pages can have the following:

Code:
<img src="mycontroller/serve_images/1"/>

My controller method currently has something like:

Code:
function serve_images {
  $imageString = file_get_contents('http://blah.com/myimage.gif');
  header("Content-Type: image/gif");

  // What goes here to get image into output stream?
}

My problem is: what comes next? How do I get the image's bytes/data into the output stream so the browser will recognise the data as an image and show it? I'm also not sure whether the "image string" is the right data format - or whether I need to convert the image string into a different format.

Again, apologies for my PHP/CI ignorance!

Thanks!

Matt.

[edit] - and I think I might have put this into the wrong forum! sorry!


Messages In This Thread
Serving Image from controller (warning newbie alert) - by El Forum - 08-31-2009, 04:02 PM
Serving Image from controller (warning newbie alert) - by El Forum - 08-31-2009, 05:07 PM
Serving Image from controller (warning newbie alert) - by El Forum - 08-31-2009, 05:20 PM
Serving Image from controller (warning newbie alert) - by El Forum - 08-31-2009, 06:00 PM
Serving Image from controller (warning newbie alert) - by El Forum - 08-31-2009, 06:09 PM
Serving Image from controller (warning newbie alert) - by El Forum - 08-31-2009, 11:38 PM
Serving Image from controller (warning newbie alert) - by El Forum - 09-01-2009, 01:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB