I couldn’t figure out the direct way, so I used a different method.
1. I pass the value to the redirect page
Download
2. Then, get the value and used iframe to download the file
$file_name = $_GET[‘file_name’];
echo “<iframe src=\”Yourwebsite.com/wp-content/plugins/download-monitor/download.php?id=$file_name\” height=’0′ width=’0′ style=’display:none’></iframe>
My site: https://endlessicons.com click any of the icon and click ‘Download’ button and see. It will redirect to the page then started to download it.