如何在php中使用curl,发布json数据和下载文件流

follow codes is php code ,but it don't download anything.

 $postdata=$jsonstr;
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);        
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json', 
        //'Content-Type: application/x-www-form-urlencoded"',
        'Content-Length: ' . strlen($postdata)
  ));        
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata );
    $output = curl_exec($ch);
    $info = curl_getinfo($ch);
    echo "<br/>-------------------<br/>";
    //print_r($output);
    echo "<br/>-------------------<br/>";
    mySaveFile($output, "./file.tmp");        
    curl_close($ch);

I get 'file.tmp' always is size 0.I suspect I set up a mistake for CURLOPT_HTTPHEADER, thanks for everyone help.