<----------------------tumbnailmaker.php------------------------>
<?php
if($_GET['image'])
{
$bronvanhetbestand = "img/". $_GET['image'];
//De hoogte en breedte ophalen van het plaatje
$dimensions = getimagesize($bronvanhetbestand);
//Dit is de breedte die alle plaatjes krijgen
$doelbreedte = 160;
//Hoogte en breedte toekennnen aan nieuwe variabelen
$bronbreedte = $dimensions[0];
$bronhoogte = $dimensions[1];
//De hoogte, als het nodig is, afronden
$doelhoogte = 130;
//Zeggen dat dit bestand een plaatje is
header('content-type: image/jpeg');
//Het plaatje inlezen in de variabele $image
$image = imagecreatefromjpeg($bronvanhetbestand);
//een nieuw klein plaatje maken met de gewenste grootte
$destination = imagecreatetruecolor($doelbreedte, $doelhoogte);
//Het nieuwe plaatje vullen met verkleinde plaatje
imagecopyresampled($destination, $image, 0, 0, 0, 0, $doelbreedte, $doelhoogte, $bronbreedte, $bronhoogte);
//Het plaatje weergeven
imagejpeg($destination);
//Het bronplaatje verwijderen
imagedestroy($image);
//Het doelplaatje verwijderen
imagedestroy($destination);
}
?>
<------------------------------image.php------------------------>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Image upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
// make sure you include a trailing slash '/'
$uploaddir = 'D:\\www\\img\\';
// specify the name used in the input-field
$userfilename = 'foto';
?>
<?php
// check if form has been submitted
if( isset( $_POST['set'] ) ) {
if( move_uploaded_file( $_FILES[$userfilename]['tmp_name'], $uploaddir . $_FILES[$userfilename]['name'] ) ) {
echo "<center>De foto is geupload.</center>";
$database = mysql_connect("localhost", "kevin", "rotaap");
mysql_select_db("daan", $database);
$today = date("m-d-y");
mysql_query('INSERT INTO `image` (`datum`, `image`) VALUES ("'.$today.'", "'.$_FILES[$userfilename]['name'].'")') or die(mysql_error());
}
} else {
// form has not been submitted, display form
?>
<div>
<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" id="upload">
<div>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000"/>
Foto:<br>
<input name="foto" type="file" />
<input type="submit" name="set" value="Send File" />
</div>
</form>
</div>
<?php
}
?>
</body>
</html>
<---------------------------tumbnail.php------------------------>
<?php
mysql_connect("localhost", "Usernaam", "Password");
mysql_select_db("Database");
$result = mysql_query ("SELECT * FROM image ORDER BY id DESC");
while($row= mysql_fetch_assoc($result))
{
echo"<img src='tumbnailmaker.php?image=".$row["image"]."'/> ";
}
?>
<---------------------------show.php--------------------------->
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Foto Shower</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php
$dimensions = getimagesize('img/'.$_GET['image']);
$bronbreedte = $dimensions[0]+6;
$bronhoogte = $dimensions[1]+37;
echo'
<script>
var Width = Math.round(((screen.width)-"'.$bronbreedte.'" )/"2");
var Height =Math.round(((screen.height)-"'.$bronhoogte.'" )/"2");
self.moveTo(Width,Height);
self.resizeTo('.$bronbreedte.','.$bronhoogte.');
</script>
';
?>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
echo'<img src="img/'.$_GET['image'].'"/>';
?>
</body>
</html>