sridhar_423
08-24-2006, 07:57 AM
Hi all,
I'm trying to display an image which is uploaded.
here is the code..
$tmp_file_name = $_FILES["file1"]["tmp_name"];
$xct_file_name = $_FILES["file1"]["name"];
@is_uploaded_file($tmp_file_name) or die("Cannot Upload file");
list($src_width,$src_height,$image_type,$html_attributes) = getimagesize($tmp_file_name);
@$image_type==2 or die("Pls Upload only JPG's");
$percentage = $_POST["percent"];
if($percentage > 0){
$dest_width = round($src_width*$percentage/100);
$dest_height = round($src_height*$percentage/100);
}else{
$dest_width = 100;
$dest_height = 100;
}
$tmp_img = @imagecreatetruecolor($dest_width,$dest_height) or die("Can't create a tmp Image");
$tmp_img = @imagecopyresampled($tmp_img,$tmp_file_name,0,0,0,0,$dest_width,$dest_height,$src_width,$src_height) or die("encountered problem in shrinking");
header("Content-Type:image/jpeg");
imagejpeg($tmp_img);
die();
nothing is being displayed. I couldnot find out whats wrong in here. I've just started learning how to stream images using PHP. cany anyone tell me where it is going wrong.
I know that my next question is going to make you laugh like anything.. . .but it has become a big sorrow for me.. what is the full form of "GD" in GD library..
I'm using Version 4.1.3. I dont know how to check whether GD is installed or something like that :(
Thanks,
Sridhar
I'm trying to display an image which is uploaded.
here is the code..
$tmp_file_name = $_FILES["file1"]["tmp_name"];
$xct_file_name = $_FILES["file1"]["name"];
@is_uploaded_file($tmp_file_name) or die("Cannot Upload file");
list($src_width,$src_height,$image_type,$html_attributes) = getimagesize($tmp_file_name);
@$image_type==2 or die("Pls Upload only JPG's");
$percentage = $_POST["percent"];
if($percentage > 0){
$dest_width = round($src_width*$percentage/100);
$dest_height = round($src_height*$percentage/100);
}else{
$dest_width = 100;
$dest_height = 100;
}
$tmp_img = @imagecreatetruecolor($dest_width,$dest_height) or die("Can't create a tmp Image");
$tmp_img = @imagecopyresampled($tmp_img,$tmp_file_name,0,0,0,0,$dest_width,$dest_height,$src_width,$src_height) or die("encountered problem in shrinking");
header("Content-Type:image/jpeg");
imagejpeg($tmp_img);
die();
nothing is being displayed. I couldnot find out whats wrong in here. I've just started learning how to stream images using PHP. cany anyone tell me where it is going wrong.
I know that my next question is going to make you laugh like anything.. . .but it has become a big sorrow for me.. what is the full form of "GD" in GD library..
I'm using Version 4.1.3. I dont know how to check whether GD is installed or something like that :(
Thanks,
Sridhar