Código PHP:
<?php
if (!isset($_GET['file']) || empty($_GET['file'])) {
exit();
}
$root = "usuarios/" . $_GET['user'] . "/rutas/";
$file = "nuevastarifas.rar"/*basename($_GET['file'])*/;
$path = $root.$file;
$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");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $size);
ob_clean();
flush();
// Descargar archivo
readfile($path);
} else {
die("El archivo no existe.");
}
?>
Si alguien tiene una solución o un script mejor que lo diga.
Gracias.
Edito--->> mi versión de php es 5.4 y mi hosting es 1and1, por si sirve de ayuda.