<?php

	require_once "/lib/pdo.php";

	require 'Slim/Slim.php'; 

	// $mapper=new DataMapper($DBH);

	\Slim\Slim::registerAutoloader();
	$app = new \Slim\Slim(); 



	$mapper=new DataMapper($DBH);

	$app->get('/:id', $file=function ($id) use ($mapper){ 
		
		return $mapper->showFilebyID($id); 
	}); 
	$app->run();

	if (isset($_POST['submit']))
	{	
		echo "ddd";
	}

	if (isset($_POST['submit']))
	{	
		$filename=$file->showName();
		$filesize=$file->showSize();
		header("Pragma: public"); 
		header("Expires: 0");
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Cache-Control: private",false); // нужен для некоторых браузеров
		header("Content-Type: jpg");
		header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
		header("Content-Transfer-Encoding: binary");
		header("Content-Length: ".$filesize); 
		readfile("$filename");
	}
		

	include "templates/file.html";

?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Profile</title>
</head>
<body>
	
	<form method='post' action=''>
		<input type='submit' value='скачать' />
	</form>
	

</body>
</html>