PHP
June 3, 2026 1 min read

Download file using php script

HS
HEMANT SINGH
Technical Writer & Educator
<?php

$filename = $_GET["file"];
$contenttype = "application/force-download";
header("Content-Type: " . $contenttype);
header("Content-Disposition: attachment; filename=\"" .$filename. "\";");
readfile("../files/".$filename);
exit();

?>