Ver Mensaje Individual
  #9 (permalink)  
Antiguo 10/02/2004, 16:22
jcorba
Invitado
 
Mensajes: n/a
Puntos:
Hola,

Respecto al tipo de cabeceras a enviar para descargar el archivo de las dos opciones que he puesto en el otro post me gustaría saber si con la segunda opción quedan todas las posibilidades de los distintos navegadores cubiertas.

En otro post he visto esto:
To force a download on MSIE for Windows, you don't have to use "attachment", but you need it for all other browsers. The correct code for that is then:

<?php
$filename=""; // the name the file will have on client computer
$file_to_download=""; // the name the file has on the server (or an FTP or HTTP request)
$user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
header( "Content-type: application/force-download" );
if ((is_integer (strpos($user_agent, "msie"))) && (is_integer (strpos($user_agent, "win")))) {
header( "Content-Disposition: filename=".$filename);
} else {
header( "Content-Disposition: attachment; filename="$filename);
}
header( "Content-Description: File Transfert");
@readfile($file_to_download);
?>

This code work properly on Windows (MSIE, Netscape, Mosilla, Opera) and Mac (MSIE, Netscape).

For the Mac, there is a little problem: if the file is recognized by the OS, it will open it and not force save to disk. To prevent this, ask your clients to use "save link to disk" and not click on it.


Alguien ha jugado ya alguna vez con esto y tiene una solución final o me puede remitir a algún sitio que conozca (da igual si está en ingles)????

Un saludo
Jose Corbacho