![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
10/05/2012, 13:38
|
| | Fecha de Ingreso: mayo-2012
Mensajes: 5
Antigüedad: 12 años, 9 meses Puntos: 0 | |
Tengo algo mal en este codigo, por favor ayudarme Mi problema es el siguiente, tengo un codigo que me almacena todo tipos de archivos (jpg,pdf..) en la base de datos, el tema es que cuando el usuario registra el documento o la foto todo transcurre sin problema, el tema lo tengo cuando yo quiero ver ese documento, pense que desde el hosting se podia extraer pero es imposible, y tengo este codigo pero creo que hay algo mal.
A VER SI ALGUIEN ME PUEDE ECHAR UNA MANO
<?php
//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
'file'
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 "file":
echo "<div>
<a href='getfile.php?id_documento={$obj->id_documento}'>$obj->titulo</a>
</div><hr />";
break;
}
}
//CERRAMOS LA CONEXION
mysql_close();
?> |