Script Kiddie
Beiträge: 22
Sprachen: HTML, CSS / teilweise PHP und MySQL / wenig JS und C++
Themenstarter
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
$datei = $_FILES['datei']['name'];
$datei = str_replace(" ", "_", "$datei");
$datei = htmlentities($datei);
if($_FILES['datei']['size'] < 2048000)
{
move_uploaded_file($_FILES['datei']['tmp_name'], "upload/$datei");
$file = "upload/$datei";
$target= "upload/$myid.png";
$max_width = "250";
$max_height = "350";
$quality = "100";
$src_img = imagecreatefromjpeg($file);
$picsize = getimagesize($file);
$src_width = $picsize[0];
$src_height = $picsize[1];
if($src_width > $src_height)
{
if($src_width > $max_width)
{
$convert = $max_width/$src_width;
$dest_width = $max_width;
$dest_height = ceil($src_height*$convert);
}
else
{
$dest_width = $src_width;
$dest_height = $src_height;
}
}
else
{
if($src_height > $max_height)
{
$convert = $max_height/$src_height;
$dest_height = $max_height;
$dest_width = ceil($src_width*$convert);
}
else
{
$dest_height = $src_height;
$dest_width = $src_width;
}
}
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imagejpeg($dst_img, "$target", $quality);
// Thumbnail
$file2 = "upload/$datei";
$target2= "upload/$myid-thumb.png";
$max_width = "50";
$max_height = "75";
$quality = "100";
$src_img = imagecreatefromjpeg($file2);
$picsize = getimagesize($file2);
$src_width = $picsize[0];
$src_height = $picsize[1];
if($src_width > $src_height)
{
if($src_width > $max_width)
{
$convert = $max_width/$src_width;
$dest_width = $max_width;
$dest_height = ceil($src_height*$convert);
}
else
{
$dest_width = $src_width;
$dest_height = $src_height;
}
}
else
{
if($src_height > $max_height)
{
$convert = $max_height/$src_height;
$dest_height = $max_height;
$dest_width = ceil($src_width*$convert);
}
else
{
$dest_height = $src_height;
$dest_width = $src_width;
}
}
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imagejpeg($dst_img, "$target2", $quality);
unlink($file);
}
else
{
echo "<center><b>Das Bild darf nicht größer als 2MB sein</b></center>";
}
|
