hi,
i want to upload image,resize(thumbnail),copy in dir and store thumbnail path in table.iam using only jpeg/gif uploads.problem is it is uploading jpeg’s
only but not gif’s.the GD version is 2.0.22
it is showing this error.
Call to undefined function: imagegif() in c:appservwwwimageuploadindir.php on line 27
here is my code
[code=php]
<?php
if(isset($_POST[‘submit’]))
{
$new_height=100;
$new_width=100;
$allowed_types = array(
‘image/pjpeg’,
‘image/gif’,
‘image/png’,
‘image/jpeg’);
if(in_array($_FILES[‘thefile’][‘type’], $allowed_types))
{
copy ($_FILES[‘thefile’][‘tmp_name’], $_FILES[‘thefile’][‘name’]) or die (mysql_error());
echo “Name: “.$_FILES[‘thefile’][‘name’].””;
echo “Size: “.$_FILES[‘thefile’][‘size’].””;
echo “Type: “.$_FILES[‘thefile’][‘type’].””;
$imagefile=$_FILES[‘thefile’][‘name’];
list($width, $height) = getimagesize($_FILES[‘thefile’][‘name’]);
$image_p = imagecreatetruecolor($new_width,$new_height);
if ($_FILES[‘thefile’][‘type’] == “image/gif”)
{
$img = @imagecreatefromgif($imagefile);
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$thename=$_FILES[‘thefile’][‘name’];
$thenames=”thumb$thename”;
$location=”c:/Appserv/www/dir7/”.$thenames;
imagegif($image_p,$location, 100);}
else
{
$img = @imagecreatefromjpeg($imagefile);
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$thename=$_FILES[‘thefile’][‘name’];
$thenames=”thumb$thename”;
$location=”c:/Appserv/www/dir7/”.$thenames;
imagejpeg($image_p,$location, 100);
}
}
else
{
print “<br>Only Gifs and Jpegs are supported. Back to <A href=’uploadimage.php’>Control Panel</a>”;
}
}
$conn4=mysql_connect(“localhost”,””,””);
mysql_select_db(“mrj”,$conn4);
$query = “INSERT INTO image_path (path) VALUES (‘$location’)”;
mysql_query($query) or die(‘Error, query failed : ‘ . mysql_error());
echo “<br>File uploaded<br>”;
?>
[/code]
uploadimage.php
<form name=’form1′ method=’post’ action=’imageuploadindir.php’ enctype=’multipart/form-data’>
Select File
<input type=’file’ name=’thefile’>
<input type=’submit’ name=’submit’ value=’upload’>
</form>