El enlace que te brindó Panino5001 es bueno, aunque se puede mejorar usando la librería
fileinfo y solo indicar aquello que no se pueda descargar.
Código PHP:
Ver original<?php
function dl_file($file){
//First, see if the file exists
if (!is_file($file)) { die("<b>404 File not found!</b>"); }
//Gather relevent info about file
//This will set the Content-Type to the appropriate setting for the file
switch( $realExtention ){
case 'text/x-php':
case 'text/html':
case 'application/x-empty':
case 'text/plain': die('error'); }
//Begin writing headers
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: $realExtention");
//Force the download
header("Content-Disposition: attachment; filename=$filename;"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$len); }
dl_file('foo.png');
Algo así es que lo haría.