Evo deo koda
header('Content-Type: image/png');
echo $this->chart->getChart();
------------------------------------
public function getChart(){
return $this->_execute();
}
private function _execute() {
$ch = curl_init('http://chart.apis.google.com/chart?chid='.md5(uniqid(rand(), true)).'&'.http_build_query($this->_post));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, count($this->_post));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->_post));
$response = curl_exec($ch);
$file = fopen('/path/to/test/graph.png', 'w+');
fwrite($file, $response);
fclose($file);
return $response;
}
Ova skripta se nalazi na http://helpmenow.dalibor-sojic.info/adsl/graph
$file = fopen('/path/to/test/graph.png', 'w+'); se nalazi u http://helpmenow.dalibor-sojic.info/test/ (graph.png)
http://helpmenow.dalibor-sojic.info/test/difference.png je razlika izmedju graph.png (na skrinu pise grapn.txt) i fajl u pozadini (sa jedan red na pocetku visak) je resultat od
header('Content-Type: image/png');
echo $this->chart->getChart();
Odakle dolazi taj jedan red visak?
Znaci... kad response snimim u fajl, sve je OK sa .png, a kad pokusam da prikazem response sa header funkciji, imam viska enter.