Ver Mensaje Individual
  #8 (permalink)  
Antiguo 05/09/2011, 06:58
Avatar de Patriarka
Patriarka
 
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 3 meses
Puntos: 288
Respuesta: Descarga con PHP me trae un archivo casi vacío

te quedaria algo asi:
pero como dice sourcegeek, yo te entiendo pero vos tambien pone tu parte
Código PHP:
Ver original
  1. <?php
  2.      $f = $_GET["f"];
  3.     $file_name= $f ;  //ARCHIVO A DESCARGAR
  4.      
  5.     $file_download_name =  $f ;   //NUEVO NOMBRE DEL ARCHIVO
  6.     $file_type = "pdf";  //EXTENSION DEL ARCHIVO
  7.     if($fh = fopen($file_name, "r")){
  8.      
  9.         $file_content = fread($fh, filesize($file_name));
  10.        
  11.         header("Pragma: public");
  12.         header("Expires: 0");
  13.         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  14.        
  15.         header("content-Type: application/force-download");
  16.         //header("content-Type: application/octet-stream");
  17.         header("Content-type: application/". $file_type. "");
  18.        
  19.         header("Content-disposition:  attachment; filename=". $file_download_name);
  20.         header("content-Transfer-Encoding: binary");
  21.        
  22.         echo $file_content;
  23.        
  24.         fclose($fh);
  25.     } else {
  26.         echo "error...";
  27.     }
  28.     ?>