Welcome folks today in this blog post we will be
forcing download a file from server as a attachment in browser using
php 7.All the full source code of the application is given below.
In order to get started you need to make an
index.php file and copy paste the following code
<?php $file_path = 'path_to_file/dummy_file.zip'; $filename = 'downloaded_file.zip'; header("Content-Type: application/octet-stream"); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"".$filename."\""); echo readfile($file_path); ?>