Download File in php

Download File in php function. Force Download.

Here, $filepath = File Full path, where the file exists.

$filename = File name of the file , which have to download ,LIKE: file1.txt
header('Content-Description: File Transfer');

header('Content-Type: application/force-download');

header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";");

header('Content-Transfer-Encoding: binary');

header('Expires: 0');

header('Cache-Control: must-revalidate');

header('Pragma: public');

header('Content-Length: ' . filesize($filename));

ob_clean();

flush();

//showing the path to the server where the file is to be download

readfile($filepath . $filename); 

exit;