0

I'm working on a web page where a user can download a file but only after accepting the license, so I made the process using PHP to check if the user checked the license and to not reveal the file's URL, the code works just fine as I wanted (downloading), here is the code :

$fileName = $_GET['AppName'] . " - Setup.exe";

$path = 'JO9E/' . $fileName;
$size = filesize($path);

header('Content-Type: application/octet-stream');
header('Content-Length: ' . $size);
header('Content-Disposition: attachment; filename=' . $fileName);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');

$file = @ fopen($path, 'rb');

if($file) {
    $_SESSION["TEMP"] = "nO";
    fpassthru($file);
    echo "<script type='text/javascript'>window.close();</script>";
}

But now my issue is :

I have IDM (Internet Download Manager) installed on my computer, and when i want to download the file... IDM shows the download box to download the file, revealing the PHP file path, and also it will not download the file when i hit start download, it losses the connection.

Now i don't have a problem revealing the PHP file path since it will not download anything unless the user accepted the license and came from the correct web page, but i want at least the user to be able to download the file even if he had IDM installed, because at this setup if the user had IDM installed, he must turn of the integration functionality in IDM in order to download the file through the browser correctly.


Hope someone can help me with this.

Mousa Alfhaily
  • 1,260
  • 3
  • 20
  • 38
  • should we know what IDM is ? –  Jun 11 '18 at 22:45
  • @smith IDM is a popular shortcut for a popular app which is **'Internet Download Manager'** to download files faster. – Mousa Alfhaily Jun 11 '18 at 22:49
  • 1
    you really shouldn't have that echo after `fpassthru()` –  Jun 11 '18 at 22:54
  • 2
    You should not directly concatenate a `$_GET` parameter into a file path like that. You've given the internet a easy way to retrieve any readable file on your server. – Sammitch Jun 11 '18 at 22:59
  • @Sammitch That is a good point, but don't worry, this is not the full file, I tweaked it before posting it here ;) ...I've thought of that, but thanks for pointing at this any way. – Mousa Alfhaily Jun 11 '18 at 23:04

1 Answers1

1

you should put a small instruction next to your download link with right click and press Save As

IDM browser extension catches all files with extensions that are selected in the IDM options.so it is on bowser level.

Ahmed M. Matar
  • 514
  • 1
  • 5
  • 13