|
|
|
|
![]() ![]() |
Jun 8 2008, 01:25 PM
Post
#11
|
|
|
Newbie [Level 1] ![]() Group: [HOSTED] Posts: 21 Joined: 31-October 07 Member No.: 52,277 |
maybe my solution will be helpful
at first create a folder 'images_full' create an upload script: CODE <html> <head> <title>Upload foto</title> </head> <body> <? if($img): $date=date("Y-m-d"); copy($img,"images_full/".$img_name); list($width,$height)=getimagesize("images_full/".$img_name); $insert=mysql_query("insert into $tabulka(image,descript,date,width,height) values('$img_name','$_POST[obr_popis]','$date','$width','$height')"); ?><img style="visibility:hidden;" src="th2.php?f=<? echo $img_name;?>&width=110&height=80&u=images_small" /> <div> <table border="0" cellspacing="0" cellpadding="0"> <tr><td>Foto: </td><td><form method="post" enctype="multipart/form-data" onsubmit="" > <input size="10" type=file name="img" accept="image/*" /></td> </tr> <tr><td><input type="submit" value="vloz" /></td> </tr> </form> </table> </div> </body> </html> the script uses another script th2.php to change the size of the image (u can select the maximal width and height) and save it, even the full size image is saved in 'images_full' folder : CODE <? header ("Content-type: image/jpeg");//vygeneruje thumbnail if(!$_GET[width]||!$_GET[height]): $new_width=133;//rozmery do ktorych sa ma obrazok zmestit $new_height=100; else: $new_width=$_GET[width]; $new_height=$_GET[height]; endif; $nasobic=$new_width/$new_height; $filename="images_full/".$_GET[f]; $path=$_GET[u]."/".$_GET[f]; $type=substr($filename,strpos($filename,'.')+1,strlen($filename)-strpos($filename,'.')); if ($type=="jpg"||$type=="JPG"){ $obrazok =imagecreatefromjpeg($filename); } elseif($type=="gif"||$type=="GIF"){ $obrazok =imagecreatefromgif($filename); } elseif($type=="png"||$type=="PNG"){ $obrazok =imagecreatefrompng($filename); } list($width,$height)=getimagesize($filename); if($width>$height*$nasobic)://vypocet rozmerov $new_height=round($height*$new_width/$width,0); else: $new_width=round($width*$new_height/$height,0); endif; $obr=imagecreatetruecolor ($new_width,$new_height); imagecopyresampled($obr, $obrazok,0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($obr,$path,100); ?> save this code to th2.php |
|
|
|
Jun 10 2008, 04:35 AM
Post
#12
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 411 Joined: 9-February 08 Member No.: 57,615 |
That looks really good, I should try it. Thanks
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 07:32 PM |