PHP hide download link

This is php code that I use to hide the download link to files.

$filename = strrev($downloads[$id]);
$filename = explode("/", $filename);

# Remote file size
$ary_header = get_headers($downloads[$id], 1);     
$filesize = $ary_header['Content-Length'];
$type = $ary_header['Content-Type'];

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-type: '.$type);
header('Content-Disposition: attachment; filename="'.strrev($filename[0]).'"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$filesize);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.