I am trying to set the filename in the Content-Disposition as the $fileName variable, but when I do it like in the following piece of code, the format of the archive comes wrong, and the name comes as $fileName. If i leave the filename empty, it works, but the name comes as the default name of the page.
<?php
if(isset($_GET['file'])){
$fileName = basename($filePath);
$filePath = $_GET['file'];
if(file_exists($filePath)){
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename=$filePath');
header('Content-Control: public');
readfile($filePath);
exit;
}else{
echo 'no doc';
}}?>