I have a link to csv file. I want to safe this file to my server using PHP. How can I do this? When I use cURL & file's functions (fopen, fputs, fclose):
$url = "https://tracker-api.toptal.com/reports/summary_csv?project_ids[]=226400&worker_ids[]=75647&start_date=2018-08-01&end_date=2018-08-07&access_token=MmNLelZwczlvekVXb2o0dnFVYWl2U2dTaEQ0OEdHNzhGK0hZOFB5b0dENWpQa1U4Z0xGWlhYa2pTaEwzV3FFVS0tSXQrZmdzdTBLTENMUmxHNEZpdklFUT09--0af46f6d677a8034fb89d9d24e135e6604e83870";
$ch = curl_init();
$source = $url;
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
$destination = __DIR__.'/files/data.csv';
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
I have wrong encoding of the file: