I'm not familiar with this function in PHP, but what you are doing matches both my reading of the php manual & my knowledge of the equivalent C function.
It shouldn't make a difference, but try the "int file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] )" function which is documented as doing an fopen, fwrite, fclose sequence .. if that does work it suggests a bug in fwrite. HTH Bruce On Sun, Dec 19, 2010 at 8:08 PM, Jochen Daum <[email protected]> wrote: > Hi, > anyone aware of a problem where fwrite stops writing when hitting the \x00 > character. > I'm downloading a zip file into a string with curl, then trying to write it > to disk: > > > $ch = curl_init(); > curl_setopt($ch, CURLOPT_URL, MABEL_URL.'/export'); > curl_setopt($ch, CURLOPT_HEADER, 0); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'readHeader'); > $return = curl_exec($ch); > curl_close(); > $fn = TMP_FILE_FOLDER.'/'.$GLOBALS['fileName2Save']; > $fh = fopen ($fn,'w+b'); > $x = fwrite($fh, strlen($return)); > fclose($fh); > > --> $x returns 4. > $return looks fine in my debugger, roughly like this: > PK\x03\x04\x14\x00\x00\x00\x08\x00ö > “=“.\x02Ò£\x01\x00\x00ˆ\x06\x00\x00"\x00\x00\x00R20101219_598983_APS0001_10000.XML....... > > > Any ideas what I;m doing wrong? > Thanks for any help. > Kind Regards,\ > Jochen > > > > -- > NZ PHP Users Group: http://groups.google.com/group/nzphpug > To post, send email to [email protected] > To unsubscribe, send email to > [email protected] -- Bruce Clement Home: http://www.clement.co.nz/ Twitter: http://twitter.com/Bruce_Clement Google Buzz: http://www.google.com/profiles/aotearoanz "Before attempting to create something new, it is vital to have a good appreciation of everything that already exists in this field." Mikhail Kalashnikov -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
