Download files with php script example

Simple code for downloading files

Place this code in a php file and make links to it. That links will be act as download link for the file .





<?php
$filename="left.txt";

$type=filetype($filename);

header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename");
header("Content-Transfer-Encoding: binary");
header('Pragma: no-cache');
header('Expires: 0');
// Send the file contents.
set_time_limit(0);
//readfile($file);


 ?>

0 comments: