Here you will find how to download a file using PHP by Using PHP Curl:
<?php
$url = 'https://www.mcqbuddy.com/img/user.jpg';
// Initialize the cURL session
$session = curl_init($url);
// Initialize the directory name where the file will be saved
$dir = './';
$file_name = basename($url);
// Save file
$save = $dir . $file;
// Open file
$file = fopen($save, 'wb');
// defines the options for the transfer
curl_setopt($session, CURLOPT_FILE, $file);
curl_setopt($session, CURLOPT_HEADER, 0);
curl_exec($session);
curl_close($session);
fclose($file);
?>