Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/09/2015, 11:07
alonsomaxx
 
Fecha de Ingreso: julio-2012
Mensajes: 81
Antigüedad: 11 años, 8 meses
Puntos: 3
Respuesta: Error descarga archivos

Esté es todo el código y con etiquetas de apertura y de cierre
Además he añadido el exit como me indicaste
Código PHP:
<?php
    
function Downloads() {
        if (!isset(
$_GET['archi']) || empty($_GET['archi'])) {
            exit();
        }
        
        
$root "download/";
        
$file basename($_GET['archi']);
        
$path $root $file.".zip";      
        
$type '';

        if (
is_file($path)) {
            
$size filesize($path);
            
            if (
function_exists('mime_content_type')) {
                
$type mime_content_type($path);
                
            } else if (
function_exists('finfo_file')) {
                
$info finfo_open(FILEINFO_MIME);
                
$type finfo_file($info$path);
                
finfo_close($info);
            }
            if (
$type == '') {
                
$type "application/force-download";
            }
            
// Definir headers
            
            
header("Content-Type: $type");
            
header("Content-Disposition: attachment; filename=$file.zip");
            
header("Content-Transfer-Encoding: binary");
            
header("Content-Length: " $size);  //Esta linea da error en localhost

            // Descargar archivo
            
readfile($path);
            exit(); 

        } else {
            die(
"El archivo no existe.");
        }
    }
?>