«
»

2012, alberto, php, programación, tenerife

Descarga Forzada de archivos con php

03.14.12 | Comment?

Alberto Suárez Pérez

Encontré este script para forzar la bajada de archivos.


$filename = $_GET['file']; //Get the fileid from the URL 
    header("Pragma: public"); 
    header("Expires: 0"); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    header("Content-Type: application/force-download"); 
    header("Content-Type: application/octet-stream"); 
    header("Content-Type: application/download"); 
    header("Content-Disposition: attachment; filename=".basename($VAR['FileName']).";"); 
    header("Content-Transfer-Encoding: binary"); 
    header("Content-Length: ".filesize($VAR['FileName'])); 

    @readfile($VAR['FileName']); 
    exit(0); 
}else{ 
    header("Location: /"); 
    exit; 
} 
?> 

files.php

Download

Comments are closed.


«
»