Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/05/2012, 14:56
matt_1985
 
Fecha de Ingreso: enero-2011
Ubicación: /root
Mensajes: 530
Antigüedad: 13 años, 4 meses
Puntos: 61
Respuesta: Link roto al mirar fotos traídas desde mysql

yo te recomiendo guardar la imagen en un directorio y el nombre de la imagen o la ruta en la base de datos , este script te podría servir.

Código PHP:
Ver original
  1. <?php
  2. if (!isset($_GET['file']) || empty($_GET['file']) && !isset($_GET['sid']) || empty($_GET['sid'])){
  3. * * echo 'Debes indicar ambos parametros !!';
  4. * * exit();
  5. }
  6. $idusuario=$_GET['sid'];
  7. $archivo=$_GET['file'];
  8. $directorio = '../upload/archivos/'.idusuario.'/files/';
  9. $archivo = basename($archivo);
  10. $path = $directorio.$archivo;
  11. $tipo = '';
  12. *
  13. if (is_file($path)) {
  14. * * $tamano = filesize($path);
  15. * * if (function_exists('mime_content_type')) {
  16. * * * * $tipo = mime_content_type($path);
  17. * * } else if (function_exists('finfo_file')) {
  18. * * * * $info = finfo_open(FILEINFO_MIME);
  19. * * * * $tipo = finfo_file($info, $path);
  20. * * * * finfo_close($info);
  21. * * }
  22. * * if ($tipo == '') {
  23. * * * * $tipo = "application/force-download";
  24. * * }
  25. * * // Leer cabeceras
  26. * * header("Content-Type: $tipo");
  27. * * header("Content-Disposition: attachment; filename=$archivo");
  28. * * header("Content-Transfer-Encoding: binary");
  29. * * header("Content-Length: " . $tamano);
  30. * * // Descargar Archivo
  31. * * readfile($path);
  32. } else {
  33. * * die('El archivo que indicaste no existe!!');
  34. }
  35. ?>


Saludos ..