Oto kod. Zapisuje pusty plik. Co jest nie tak??
ob_start();
$nazwa=convertname($text);//nazwa pliku dostępnego po zalogowaniu
$link=convertstring($text);//link do pliku dostępnego po zalogowaniu
...
//logowanie
...
//pobieranie
$fh = fopen($nazwa, 'w');
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname( __FILE__ ).'/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname( __FILE__ ).'/cookie.txt');
curl_setopt($ch, CURLOPT_FILE, $fh);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
if($link)
{
$link2='http://'.$link;
ob_get_clean();
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($link2).";");
header("Accept-Ranges: bytes");
header("Content-Transfer-Encoding: binary");
readfile(convertname($text));
exit;
}
ob_end_flush();