Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/09/2011, 08:14
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

proba con esto:
Código PHP:
Ver original
  1. <?php
  2.  
  3. $file_name=$_REQUEST['file_name'];  //ARCHIVO A DESCARGAR
  4.  
  5. $file_download_name = $_REQUEST['file_download_name'];   //NUEVO NOMBRE DEL ARCHIVO
  6. $file_type = "xlsx";  //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. ?>