Welcome Guest ( Log In | Register)



2 Pages V  < 1 2  
Reply to this topicStart new topic
> Image Upload, ?!?
majklisko
post 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
Go to the top of the page
 
+Quote Post
alex1985
post 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
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Alphanumeric Upload Sorting(0)
  2. Using The Image Editing Functions Of Php(4)
  3. Upload Pics With Php?(6)
  4. Write Random Text To Image(5)
  5. I Need A Php Editor(1)
  6. Image Upload And File Size(2)
  7. Php Photo And Image Gallery Script(2)
  8. Image Galleres(10)
  9. Dynamic Image / Signature Generator(12)
  10. Watermark Your Image With Simple Php Script(35)
  11. Looking For Php Script : Image Thumbnail Like Imageshack.(2)
  12. Wappyftp V1.00(8)
  13. Detect Image Resolution Without Gd(1)
  14. Flipping An Animated Gif Image W/ Gd Library(1)
  15. Trap17 Board Status Dynamic Image(13)
  1. Batch Upload Script(1)
  2. File Upload(1)
  3. Php And Flash Image Gallery(5)
  4. Get A Image Indentifier With Gd Library(7)
  5. Php Ftp Upload Form(1)


 



- Lo-Fi Version Time is now: 6th September 2008 - 07:32 PM