Create a PHP page with the following:
<?php $filepath = "path/to/file.ext"; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$filepath"); header("Content-Type: mime/type"); header("Content-Transfer-Encoding: binary"); // UPDATE: Add the below line to show file size during download. header('Content-Length: ' . filesize($filepath)); readfile($filepath); ?>
Give $filepath
path to the file to be uploaded and set the Content-Type
to the mime type of the uploaded file.
Send the download link to this page.
For multiple files of the same type:
<?php $filepath = $_GET['filepath']; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$filepath"); header("Content-Type: mime/type"); header("Content-Transfer-Encoding: binary"); // UPDATE: Add the below line to show file size during download. header('Content-Length: ' . filesize($filepath)); readfile($filepath); ?>
Replace the information above and specify the “download” link to this page with the GET parameter named “file path” containing the file path.
For example, if you name this php file “download.php”, specify the download link for the file named “movie.mov” (in the same directory as download.php) to “download.php? Filepath = movie. mov ".
source share