should contain what you need. just play around with it or something
Code:
function changeavatar($info) {
if ($_POST['imgpost']) {
/*echo $_FILES['picture']['name'];*/
$allowed_types = array(
'image/gif',
'image/jpeg');
if(in_array($_FILES['picture']['type'], $allowed_types)) {
list($width, $height) = getimagesize($_FILES['picture']['tmp_name']);
if ($_FILES['picture']['type']=='image/jpeg')
$image = imagecreatefromjpeg($_FILES['picture']['tmp_name']);
else
$image = imagecreatefromgif($_FILES['picture']['tmp_name']);
/* if ($this->width && ($width_orig < $height_orig)) {
$this->width = ($this->height / $height_orig) * $width_orig;
} else {
$this->height = ($this->width / $width_orig) * $height_orig;
}
*/
$newheight = (160 / $width) * $height;
$image_p = imagecreatetruecolor(160, $newheight);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 160, $newheight, $width, $height);
imagejpeg($image_p,'avatar/'.$info['alias'].'_-_avatar.jpg', 80);
$image_p = imagecreatetruecolor(30, 30);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 30, 30, $width, $height);
imagejpeg($image_p,'avatar/'.$info['alias'].'_-_icon.jpg', 80);
/*imagejpeg($image,'avatar/'.$info['alias'].'_-_full.jpg', 80);
*/
echo 'Avatar uploaded successfully. (old avatar might appear due to cache)<br>';
/* echo '<img src="avatar/'.$info['alias'].'.jpg"><br><br>';*/
imagedestroy($image_p);
imagedestroy($image);
}
}
{
showavatar($info['alias'],"avatar");
echo '<br><br>Select & send your JPEG/GIF avatar';
echo '<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="picture">
<input name="imgpost" type="submit" value="Send">
</form>';
}
}