Dobry den mam funkci poro prepocet obrazku ale tady se obrazky zobrazuji primo na prohlizec tak jsme se chtel zeptat jak by se to dalo upravit aby do ten zmenseny obrazek ulozilo do adresare napr obrazky/
Diky moc Petr
<?php
if (!$max_width)
$max_width = '500';
if (!$max_height)
$max_height = '500';
$size=GetImageSize($image);
$width=$size[0];
$height=$size[1];
$x_ratio=$max_width/$width;
$y_ratio=$max_height/$height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
switch ($size[2]) {
case 1: $src=imagecreatefromgif($image); break;
case 2: $src=imagecreatefromjpeg($image); break;
case 3: $src=imagecreatefrompng($image); break;
}
$dst=ImageCreateTrueColor($tn_width,$tn_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0,$tn_width,$tn_height,$width,$height);
ImageJpeg($dst,null,-1);
ImageDestroy($src);
ImageDestroy($dst);
?>
ImageJpeg($dst,null,-1);
zmen na
ImageJpeg($dst,"obrazky/" . $meno_povodneho_suboru);
Moc diky jes se chci jeste zeptat jak z tohohle udelam funkci aby mi to fungovalo kdyz poslu pres formular (<input type="file"...) chtel udelat aby pokud nahravam obrazek tak aby to zmenilo velikost na 500 a ulozil obrazek ale nemuzu prijit na to jak to udelat diky moc
Petr:
HTML formular musi vypadat nejak takto:
<form method="post" enctype="multipart/form-data" action="upload.php">
<input type="file" name="uploaded_image">
<input type="submit" value="upload">
</form>
a kod v upload.php:
$type = $_FILES['uploaded_image']['type'];
$name = $_FILES['uploaded_image']['name'];
$tmp_name = $_FILES['uploaded_image']['tmp_name'];
if (eregi("image",$type)):
if (move_uploaded_file($tmp_name,"./$name")):
$image = "./$name";
// nyni prijde ten tvuj kod
else:
echo "nepodarilo se uploadovat";
endif;
else:
echo "Nespravny typ souboru";
endif;
Nejak tak, mozna jsou v tom chyby, dalsi me opravi :)