Hej!
Försöker fixa så man kan skala bilder. Får uppladdningen å fungera å allt, den flyttar orginalbilden till rätt mapp, men thumbs-mappen e tom! Why? Får inga felmess!
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl Document</title>
</head>
<body>
<?
//Starta uppladdning------------------------------------
if (isset($_FILES['imagefile'])) {
if ($_FILES['imagefile']['type'] == "image/jpeg"){
copy ($_FILES['imagefile']['tmp_name'], "org/".$_FILES['imagefile']['name'])
or die ("FEL!");
echo "";
echo "Bildnamn: ".$_FILES['imagefile']['name']."";
echo "<br>Bildstorlek: ".$_FILES['imagefile']['size']."";
echo "<br>Bildtyp: ".$_FILES['imagefile']['type']."";
echo "<br>Uppladdning klar!<br>";
}
else {
echo "<br><br>";
echo "Ej rätt filformat";
exit;
}
//-----SLUT UPPLADDNING!
// THUMBS!
$thumbsize=90;
$imgfile = $_FILES['imagefile']['name'];
//header('Content-type: image/jpeg');
list($width, $height) = getimagesize("org/".$imgfile);
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $thumbsize;
$newheight = $thumbsize/$imgratio;
}
else{
$newheight = $thumbsize;
$newwidth = $thumbsize*$imgratio;
}
$thumb = imagecreatetruecolor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb,"thumbs/".$source,100);
echo "HÄR SKRIVER VI UT THUMBS:";
echo $thumb;
echo $imgfile;
echo $thumbsize;
//-----------end--------------
}
?>
<form method="post" action="upload.php" enctype="multipart/form-data">
Ladda upp bild:<br />
<input type="file" name="imagefile" />
<br />
<input type="submit" value="Ladda upp!" />
</form>
</body>
</html>