Originariamente inviato da Sandro M.
http://www.php.phoenixweb.it/funzione-download.php
io l'avrei scritta cosi':

Codice PHP:
<?php
function download ($nome$path) {
        if( 
$fp = @fopen$path"r" ) ) {
                
$size filesize$path );
                if( 
$size ) {
                        
$binary fread ($fp$size);
                        
$nome stripslashes$nome );
                        if( 
strpos$_SERVER['HTTP_USER_AGENT'], "Gecko" ) !== false ) {
                                
$search = Array( 'Ä''Ë''Ï''Ö''Ü''ä''ë''ï''ö''ü' );
                                
$replace = Array( 'A''E''I''O''U''a''e''i''o''u' );
                                
$nome str_replace$search$replace$nome );
                        }
                        
header("Pragma: public");
                        
header("Cache-control: private");
                        
header("Expires: 0");
                        
header("Content-type: application/RFC822");
                        
header("Content-type: octet/stream\n");
                        
header("Content-transfer-encoding: binary\n");
                        
header("Content-Disposition: attachment; filename=".$nome."\n");
                        
header("Content-Length:".$size);
                        echo 
$binary;
                }
                
fclose($fp);
        }
        exit( 
);
}

// esempio
download ("bar.gif""img/bar.gif");
?>