Return to Snippet

Revision: 2140
at January 4, 2007 00:49 by sendoa


Initial Code
$dir="/path/directorio/"; 
if (isset($_REQUEST["fichero"])) { 
  $fichero=$dir.$_REQUEST["fichero"]; 
  header("Content-type: application/force-download"); 
  header("Content-Transfer-Encoding: Binary"); 
  header("Content-length: ".filesize($fichero)); 
  header("Content-disposition: attachment; filename=\"".basename($fichero)."\""); 
  readfile("$fichero"); 
} else { 
  echo "Fichero seleccionado"; 
}

Initial URL


Initial Description
Interesante script que te ayudará si no quieres que la gente acceda directamente a tus ficheros para bajárselos. Para ello lo que hará será recoger un parámetro con el fichero que se quiere bajar, añadirle el path donde se encuentra y mediante la cabecera de la respuesta (header) devolver el fichero.

Vía http://sentidoweb.com/2006/10/02/descargas-seguras-mediante-php.php

Initial Title
Descargas seguras con PHP

Initial Tags


Initial Language
PHP