Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/04/2013, 13:36
echo_
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 6 meses
Puntos: 7
Problema al redireccionar

Buen dia a todos, mi problema es que al forzar una descarga y querer redireccionar, este no me deja, alguien que me pueda echar una mano y se los agradezco de verdad.

Código PHP:
<?php

$documento
='cod_etica.pptx';
 
if (!isset(
$_GET['doc']) || empty($_GET['doc'])) {
 exit();
}else{
$root "descargas/";
//$file = basename($_GET['file']);
$file basename($documento);
$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);
 
// Descargar archivo
 
readfile($path);
header('Location: index.php');
} else {
 die(
"El archivo no existe.");
}

}
 
?>