In php we can easily download file using header and easy and simple script to download file given below.
php code
<?php
if($_REQUEST['c'])
{
$fnm="res/".$_REQUEST['c'];
header('Content-Disposition: filename='.basename($fnm));
header('Content-Type: application/'.filetype($fnm));
header('Size='.filesize($fnm));
readfile($fnm);
//echo file_get_contents($fnm);
}
//open server side directory (res) where file placed
$od=opendir("res");
while($file=readdir($od))
{
if($file!='.' and $file!=".." and $file!="Thumbs.db")
{
echo "<a href='dwn.php?c=$file'>$file</a><br>";
}
}
?>
No comments:
Post a Comment