Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/04/2012, 08:25
matt_1985
 
Fecha de Ingreso: enero-2011
Ubicación: /root
Mensajes: 530
Antigüedad: 13 años, 3 meses
Puntos: 61
Respuesta: Sumar o unir variables

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


yo uso algo asi para contruir la ruta y forzar la descarga del archivo .

Saludos