Location: PHPKode > projects > Aukyla Document Management System > htdocs/download.php
     download.php, used for downloading files from a URI.
     Copyright (C) 2004 Arend van Beelen, Auton Rijnsburg

     This program is free software; you can redistribute it and/or modify it under the terms of the
     GNU General Public License as published by the Free Software Foundation; either version 2 of
     the License, or (at your option) any later version.

     This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
     without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
     the GNU General Public License for more details.

     You should have received a copy of the GNU General Public License along with this program; if
     not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     MA 02111-1307 USA

     For any questions, comments or whatever, you may mail me at: hide@address.com

// Uncomment the next line if you can't adjust the include_path setting in your
// php.ini file:



$file = Config::request('file');
$name = Config::request('name');

if($name == '')
	$name = basename($file);

$mime = MIME::type($name, false);
header("Content-Disposition: attachment; filename=\"$name\"");

if($mime == '')
	$mime = MIME::type($file);

header("Content-type: $mime");

$contents = URI::fileGetContents($file);
if($contents === false)
	errorPage('404', 'Not Found',
	          "The requested URL $file was not found on this server.");

echo $contents;

function errorPage($errorcode, $errorstring, $message)
	header("HTTP/1.0 $errorcode $errorstring");
	die("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n".
	    "<title>$errorcode $errorstring</title>\n".

Return current item: Aukyla Document Management System