Use this function to download file from file link using PHP.

function downloadFileFromUrl($fileUrl, $outputFileName)
{
    $options = [
        CURLOPT_FILE => fopen($outputFileName, 'w'),
        CURLOPT_TIMEOUT => 720, // increase this to prevent timeout on big files
        CURLOPT_URL => $fileUrl
    ];

    $curl = curl_init();
    curl_setopt_array($curl, $options);
    curl_exec($curl);
    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);
    return $httpCode;
}

You can use this function like this

$fileUrl = "https://sumanbhattarai.com.np/wp-content/uploads/2018/07/css.jpg";
$newName = 'css.jpg';
$httpCode = downloadFileFromUrl($fileUrl, $newName);
echo $httpCode;