I have this php code :
<?php
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"".$_GET['name']."\"");
$file_content = file_get_contents($_GET['name']);
echo $file_content;
?>
In this case, the attacker can download files on my site with this request:
localhost/file.php?name=../../../../../../../etc/passwd
I need a way to prevent users from downloading anything except .zip
file from the current directory.