http://www.xup.dk/ny/galleri/?galleri=bdayder kommer stadig ingen fejl.
hmm
poster lige hele filen:
<?php
define ("MAX_SIZE","50000");
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
if(isset($_POST['Submit']) && $_POST['kode']=="testest")
{
$image=$_FILES['image']['name'];
if ($image)
{
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
echo '<h2>FEJL: Ukendt filtype!</h2><br><br>';
$errors=1;
}
else
{
$size=filesize($_FILES['image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
echo '<h2>FELJ: Billedet er for stort</h2><br><br>';
$errors=1;
}
$image_name=time().'.'.$extension;
//the new name will be containing the full path where will be stored (images folder)
$newname="bday/".$image_name;
//we verify if the image has been uploaded, and print error instead
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied)
{
echo '<h2>FEJL: Prøv igen..</h2><br><br>';
$errors=1;
}}}}
//If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors && $_POST['kode']=="testtest")
{
?>
<meta http-equiv="refresh" content="1; url=?galleri=bday">
<h2>Filen er nu uploaded..</h2><br><br>
<?
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
$dir = opendir( $pathToImages );
while (false !== ($fname = readdir( $dir ))) {
$info = pathinfo($pathToImages . $fname);
if ( strtolower($info['extension']) == 'jpg' )
{
// load image and get image size
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
// create a new temporary image
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
// copy and resize old image into new image
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// save thumbnail into a file
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
// close the directory
closedir( $dir );
}
// call createThumb function and pass to it as parameters the path
// to the directory that contains images, the path to the directory
// in which thumbnails will be placed and the thumbnail's width.
// We are assuming that the path will be a relative path working
// both in the filesystem, and through the web for links
createThumbs("bday/","bday/thumbs/",860);
}if(isset($_POST['kode']) && $_POST['kode']!="testtest"){?>
<h2>FEJL: Forkert kode!</h2><br><br>
<?}?>
<?include("upload_form.php");?>
<hr>
<h2>Galleri: Fest</h2>
<?php
// Angiver antal før der skal laves seperation/linjeskift
$seperator_nr = 4;
// Angiver vores tæller, starter fra 1
$i = 1;
while() {
// Tjekker om $i går lige op i det angivne seperations/linjeskift nr.
if($i % $seperator_nr == 0) {
echo "<br />";
}
// Forhøjer vores tæller med 1
$i++;
}
?>