function only downloads the first file

0

I'm developing a more download function I went to see in the downloads folder that it only completes the first downloaded file, the rest is 0KB in size, it follows part of the code below.

function download($link) {

$rand = rand(1, 1466);
$remote_file_url = $link;
$downloadedFileName = $rand . ".mp4";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $remote_file_url);
$downloadedFile = fopen($downloadedFileName, 'w+');
curl_setopt($ch, CURLOPT_FILE, $downloadedFile);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_exec($ch);
curl_close($ch);
fclose($downloadedFile);
header('Content-type: video/mp4');
ob_clean();
flush();
readfile($downloadedFileName);
}
    
asked by anonymous 30.03.2018 / 00:06

0 answers