Wednesday 28 November 2012

Download Link Using PHP


Create a download link using PHP.

It needs two files index.php and download.php, this is just for an representation. Below is the code:

index.php
<a href="download.php?file=conent.zip" title="Download">
       <b>Download file</b>
</a>

download.php

<?php
$file =$_GET['file'];
header("Content-type: application/text");
header("Content-Disposition: attachment; filename=". $file);
readfile($file);
?>

No comments:

Post a Comment