header function filename is not working in php : header function filename is not working in php. i try to export a csv file but it always download the page name only like export.php
i try so many code and force download. but i can't. plz anyone hlp me

    enter code here
    if(isset($_POST["export"]))
    {    include 'database/config.php';
         include "database/database.php";
         $db = new database();
         $fn = "csv_".uniqid().".csv";

         $file = fopen($fn, "w");
         $query = "SELECT * from wp_terms";
         $read = $db -> select($query);
         fputcsv($file, array('ID', 'Name', 'slug', 'term group'));
         if($read) {
            while ($row = $read->fetch_assoc()) {
              fputcsv($file, $row);
            }
          }
         header('Content-Type: text/csv; charset=utf-8');
         header('Content-Disposition: attachment; filename="'.$fn);
  
         fclose($file);
       }

  