Ver Mensaje Individual
  #4 (permalink)  
Antiguo 03/02/2011, 16:41
gonzalodolzani
 
Fecha de Ingreso: febrero-2011
Mensajes: 3
Antigüedad: 13 años, 2 meses
Puntos: 0
Pregunta Respuesta: [AYUDA] Permitir descargar dato BYTEA de Postgres

Hola de nuevo...probé lo que me indicaste...
pero me genera este reporte:

Cita:
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\HCI\index.php:8) in C:\AppServ\www\HCI\index.php on line 50

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\HCI\index.php:8) in C:\AppServ\www\HCI\index.php on line 52
Este es mi código, como para que tengas una idea. En el que entre otros datos pido el archivo binario.

:(

Código PHP:
<?php
      
// make our connection
      
$connection pg_connect("host=localhost port=5432 dbname=bd user=postgres password=admin");
      
      
// let me know if the connection fails
      
if (!$connection) {
        print(
"Connection Failed.");
        exit;
      }
      
      
// declare my query and execute
      
$myresult pg_exec($connection"SELECT id_paciente, nombre_persona, apellido_persona  
      FROM paciente pa, persona pe where pa.id_paciente = 1"
);
                
      
// Get the bytea data
      
$res pg_query("SELECT archivo_fotografia_paciente  
      FROM paciente pa where pa.id_paciente = 1"
); 
      
$raw pg_fetch_result($res0);
      
pg_free_result($res); 

header("Content-type: application/pdf");
header('Content-Disposition: attachment;
filename="'
.$res['filename'].'"');

echo 
pg_unescape_bytea($data['archivo_fotografia_paciente']);
      
// process results
      
for ($lt 0$lt pg_numrows($myresult); $lt++) {
        
$id_paciente pg_result($myresult$lt0);
        
$nombre_paciente pg_result($myresult$lt1);
        
$apellido_paciente pg_result($myresult$lt2);        
      }
        
      
// declare my query and execute
      
$myresult pg_exec($connection"select o.detalle_obra_social  
      FROM paciente pa, obra_social o where pa.id_paciente = 1"
);
      
      
// process results
      
for ($lt 0$lt pg_numrows($myresult); $lt++) {
        
$detalle_obras_social_paciente pg_result($myresult$lt0);        
      }
        
        
// print results
        
print("Id: $id_paciente<br />\n");
        print(
"Nombre: $nombre_paciente<br />\n");
        print(
"Apellido: $apellido_paciente<br />\n");
        if (
$detalle_obras_social_paciente != null)
        print(
"Obra social: $detalle_obras_social_paciente<br />\n");
        else
        print(
"Obra social: No posee<br />\n");
    
?>