Ver Mensaje Individual
  #12 (permalink)  
Antiguo 02/03/2004, 03:58
jcorba
Invitado
 
Mensajes: n/a
Puntos:
Este es el codigo que he implementado:

function descargaFichero ($fichero)
{ // HEADERS SACADAS DE PHPMYADMIN
$filename=basename($fichero);
$filesize = filesize($fichero);

// 'application/octet-stream' is the registered IANA type but
// MSIE and Opera seems to prefer 'application/octetstream'
$USR_BROWSER_AGENT="";
if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'])) $USR_BROWSER_AGENT='OPERA';
if (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'])) $USR_BROWSER_AGENT='IE';
$mime_type = ($USR_BROWSER_AGENT == 'IE' || $USR_BROWSER_AGENT == 'OPERA')
? 'application/octetstream'
: 'application/octet-stream';

header('Content-Type: ' . $mime_type);
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// IE need specific headers
if ($USR_BROWSER_AGENT == 'IE')
{
//header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else
{
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Pragma: no-cache');
}
@readfile ($fichero);
exit();
}