Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/06/2002, 12:36
Eduardo Benitez
 
Fecha de Ingreso: noviembre-2001
Ubicación: Quito - Ecuador
Mensajes: 87
Antigüedad: 22 años, 5 meses
Puntos: 0
Re: hacer en php q me pueda descargar el pdf

Ahora la pagina get.htm hace lo siguiente, muestra el ecuadro de dialogo para bajar el archivo que se hizo clic en la pagina anterio:

<?
define('FILEDIR', './downloads/');
$path = FILEDIR . $file;

//check that this file exists and that it doesn't include
//any special characters
if(!is_file($path) OR !eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file))
{
header("Location: error.php");
exit();
}

/*
** //check that the user has permission to download file
** if(user does not have permission)
** {
** //redirect to error page
** header("Location: error.php");
** exit();
** }
*/

$mimetype = array(
'doc'=>'application/msword',
'htm'=>'text/html',
'html'=>'text/html',
'jpg'=>'image/jpeg',
'pdf'=>'application/pdf',
'txt'=>'text/plain',
'xls'=>'application/vnd.ms-excel'
);

$p = explode('.', $file);
$pc = count($p);

//si quiero forzar el cuadro de dialogo no utilizar el if y utilizar los headers del else

//send headers
/* if(($pc > 1) AND isset($mimetype[$p[$pc - 1]]))
{
//display file inside browser
header("Content-type: " . $mimetype[$p[$pc - 1]] . "\n");

}
else
{ */
//force download dialog
header("Content-type: application/octet-stream\n");
header("Content-disposition: attachment; filename=\"$file\"\n");
//}
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($path) . "\n");

//send file contents
$fp=fopen($path, "r");
fpassthru($fp);
?>


Ahora lo que no entiendo es si la informacion que tienes esta en tablas de mysql o alguna BD y quieres generar un pdf dinamicamente y hacer que se puedan bajar, yo solo te envio la rutina para bajar archivos de cuaquier clase.
Especifica el problema

EduH