Force File for Download using Php | Download File on Click URL


1.       Upload the file you want to make available for download to your hosting Web server.
For example,
myhtml.html
2.       Create one another a new PHP file - I recommend naming it the same name as your downloaded file, only with the extension .php. For example:
myhtml.php
3.       Open the PHP block:
<?php
//  set the HTTP header:
header('Content-disposition: attachment; filename= myhtml.html');
// Then set the MIME-type of the file:
header('Content-type: application/html');
// Point to the file you want to download:
readfile('myhtml.html');
?>
4.       Link to your PHP file as a download link. For example:
<a href="myhtml.php">Download my html document </a>

Post a Comment

0 Comments