Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/05/2012, 06:00
lionone_21
 
Fecha de Ingreso: mayo-2012
Mensajes: 5
Antigüedad: 12 años
Puntos: 0
Respuesta: Tengo algo mal en este codigo, por favor ayudarme

Perdona mi ignorancia, pero es que con lo que me propusistes sigo sin conseguir extraer el pdf de la base datos.

Podrias indicarme exactamente los cambios?

list


<?php
//NOS CONECAMOS A LA BASE DE DATOS
//REMPLAZEN SUS VALOS POR LOS MIOS

//CONSTRUIMOS EL QUERY PARA OBTENER LOS ARCHIVOS
$qry="select
docs.*,
CASE docs.tipo
WHEN 'image/png' then
'image'
WHEN 'image/jpg' then
'image'
WHEN 'image/gif' then
'image'
WHEN 'image/jpeg' then
'image'
ELSE
'application/octet-stream'
END as display
from tbl_documentos AS docs";
//EJECUTAMOS LA CONSULTA
$res=mysql_query($qry) or die("Query: $qry ".mysql_error());
//RECORREMOS LA CONSULTA
//*********NOTA DONDE DICE alt='$obj-/>titulo' QUITA LA BARRA PARA QUE QUEDE ASI:
// alt='$obj->titulo'
// EL WORDPRESS ME ESTA REMPLAZANDO EL CODIGO
while ($obj=mysql_fetch_object($res)) {
//SI EL TIPO DE DOCUMENTO ES UMAGEN LA MOSTRAMOS SI NO SOLO HACEMOS EL LINK
switch ($obj->display){
case "image":
echo "<div>
<a href='getfile.php?id_documento={$obj->id_documento}'>
<img alt='$obj->titulo' src='getfile.php?id_documento={$obj->id_documento}'/>
</a>
</div><hr />";
break;
case "application/octet-stream":
echo "<div>
<a href='getfile.php?id_documento={$obj->id_documento}'>$obj->titulo</a>
</div><hr />";
break;
}
}

//CERRAMOS LA CONEXION
mysql_close();
?>

getfile

<?php
//CONSTRUIMOS LA CONSULTA PARA OBTENER EL DOCUMENTO

//CONSTRUIMOS LA CONSULTA PARA OBTENER EL DOCUMENTO
$qry="Select * from tbl_documentos where id_documento='{$_REQUEST['id_documento']}'";$res=mysql_query($qry) or die(mysql_error()." qry::$qry");
$obj=mysql_fetch_object($res);
//OBTENEMOS EL TIPO MIME DEL ARCHIVO ASI EL NAVEGADOR SABRA DE QUE SE TRATA
header("Content-type: {$obj->tipo}");
//OBTENEMOS EL NOMBRE DEL ARCHIVO POR SI LO QUE SE REQUIERE ES DESCARGARLO
header ("Content-Length: ".strlen($obj->contenido));
//Y PO ULTIMO SIMPLEMENTE IMPRIMIMOS EL CONTENIDO DEL ARCHIVO
print $obj->contenido;
//CERRAMOS LA CONEXION
mysql_close();
?>

Esto es lo que yo hice pero no funciona y por ciertos mil gracias por constestar