php - pass fpassthru contents to variable -


here's portion of code (taken google charts example here http://code.google.com/apis/chart/image/docs/post_requests.html) display image chart:

 $context = stream_context_create( array('http' => array(   'method' => 'post',   'content' => http_build_query($chart)))); fpassthru(fopen($url, 'r', false, $context)); 

the problem instead of displaying image directly, i'd pass contents of fpassthru (which image) variable.. perhaps 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 close file):

$f = fopen($url, 'rb', false, $context); $image = stream_get_contents($f); fcloes($f); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -