please help where am i wrong.
just need to upload and resize a image. all the GD, ZLib libraries are installed.
i need to show the upload image and the resized image togther. don't know where i m going, but i m going
thanks in advance
kalyan
<head>
<title></title>
<?
if ($REQUEST_METHOD == "POST")
{
$tmp_file_name = $imgfile;
$im = @imagecreatefromjpeg($tmp_file_name);
if( !$im ) {
$im = @imagecreatefrompng($tmp_file_name);
$is_png = false;
}
unlink($tmp_file_name);
if( !$im ) {
echo("Error in creating images from jpg");
unlink($img_link);
return;
}
$width = imagesx($im);
$height = imagesy($im);
if( $width>=$height ) {
if( $width>200 ) {
$width = 200;
$height = floor(200/imagesx($im)*$height);
}
} else {
if( $height>150 ) {
$height = 150;
$width = floor(150/imagesy($im)*$width);
}
}
$new_im = imagecreate($width,$height);
imagecopyresized($new_im,$im,0,0,0,0,$width,$height,imagesx($im),imagesy($im));
if( !$is_png ) {
if( !(imagejpeg($new_im,$img_link,80)) ) {
echo("Error in resizing images from jpg");
unlink($img_link);
return;
}
} else {
if( !(imagepng($new_im,$img_link)) ) {
echo("Error in resizing images from png");
unlink($img_link);
return;
}
}
print("<img src=\"$im\">");
/*== DO WHATEVER ELSE YOU WANT
SUCH AS INSERT DATA INTO A DATABASE ==*/
}
?>
</head>
<body bgcolor="#FFFFFF">
<h2>Upload and Resize an Image</H2>
<form action="<?=$SCRIPT_NAME; ?>" method="POST" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1024000">
<p>Upload Image: <input type="file" name="imgfile"><br>
<font size="1">Click browse to upload a local file</font><br>
<br>
<input type="submit" value="Upload Image">
</form>
</body>