note 99823 added to function.header

From: Date: Wed, 08 Sep 2010 22:50:02 +0000
Subject: note 99823 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-172393@lists.php.net to get a copy of this message
I'm trying to get image from google charts api via curl. Here is part of the code: <?php header('Content-Type: image/png'); echo $this->chart->getChart(); ___________________________ private function getChart() { $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; } ?> The problem after calling this I get error "The image can not be displayed, because it contains errors". If I open saved file /path/to/test/graph.png it is OK. The difference is 2 bites at the beginning of received response. \r\n is prepended. How can fix this? ---- Server IP: 69.147.83.197 Probable Submitter: 80.77.158.88 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/99823 Del: integrated -- https://master.php.net/note/delete/99823/integrated Del: useless -- https://master.php.net/note/delete/99823/useless Del: bad code -- https://master.php.net/note/delete/99823/bad+code Del: spam -- https://master.php.net/note/delete/99823/spam Del: non-english -- https://master.php.net/note/delete/99823/non-english Del: in docs -- https://master.php.net/note/delete/99823/in+docs Del: other reasons-- https://master.php.net/note/delete/99823 Reject -- https://master.php.net/note/reject/99823 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172393) next »