thanks big.nerd... u show me a great guidance...
it's works but I have to add some script to save the thumbnail inpng/gif also and make a transparent background.
the final codes :
function UploadImage($fupload_name){
$vdir_upload = "../image/";
$vfile_upload = $vdir_upload . $fupload_name;
move_uploaded_file($_FILES["fupload"]["tmp_name"], $vfile_upload);
$fileName = basename($vfile_upload);
$ext = substr(strrchr($fileName, '.'), 1);
// Note: The default can be removed and replaced with proper error handling, this only states if it doesnt know what it is, treat as a jpeg, as they are most common.
switch($ext) {
case "gif":
$im_src = imagecreatefromgif($vfile_upload);
break;
case "png":
$im_src = imagecreatefrompng($vfile_upload);
break;
case "jpg":
case "jpeg":
default:
$im_src = imagecreatefromjpeg($vfile_upload);
break;
} // end switch
$src_width = imageSX($im_src);
$src_height = imageSY($im_src);
//create thumbnail
$dst_width = 125;
$dst_height = ($dst_width/$src_width)*$src_height;
$im = imagecreatetruecolor($dst_width,$dst_height);
imagesavealpha($im, true);
// Create some colors and transparent background
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 25, $black);
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);
imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
//save thumbnail
switch($ext) {
case "gif":
imagegif($im,$vdir_upload . "thumb_" . $tupload_name);
break;
case "png":
imagepng($im,$vdir_upload . "thumb_" . $tupload_name);
break;
case "jpg":
case "jpeg":
default:
imagejpeg($im,$vdir_upload . "thumb_" . $tupload_name);
break; }
imagedestroy($im_src);
imagedestroy($im);
}