here's a portion of my code (taken from google charts example here http://code.google.com/apis/chart/image/docs/post_requests.html) that will display an image chart:
$context = stream_context_create(
array('http' => array(
'method' => 'POST',
'content' => http_build_query($chart))));
fpassthru(fopen($url, 'r', false, $context));
The problem is instead of displaying the image directly, I'd like to pass the contents of fpassthru (which essentially is the image) to a variable.. perhaps something like
$image = fpassthru(fopen($url, 'r', false, $context));
any idea? thanks
Use file_get_contents
:
$image = file_get_contents($url, false, $context);
or stream_get_contents
(but don't forget to close the file):
$f = fopen($url, 'rb', false, $context);
$image = stream_get_contents($f);
fcloes($f);