/    Sign up×
Community /Pin to ProfileBookmark

problem with uploading gif’s

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

imageuploadindir.php
——————-


[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>

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@bokehJan 11.2007 — Edit your post and use PHP tags around your code.
Copy linkTweet thisAlerts:
@roshanjameerauthorJan 13.2007 — hi

i did some modifications in the code but it is showing same error.

thanks

mrjameer
Copy linkTweet thisAlerts:
@NightShift58Jan 13.2007 — Note: Since all GIF support was removed from the GD library in version 1.6, this function is not available if you are using that version of the GD library. Support is expected to return in a version subsequent to the rerelease of GIF support in the GD library in mid 2004. For more information, see the GD Project site.[/quote]Do you have (1) GD support in your PHP version and if so, (2) does your GD library support GIF. See:http://us2.php.net/manual/en/function.imagegif.php

Use [b]phpinfo()[/b] to find the answer to these two questions.
Copy linkTweet thisAlerts:
@roshanjameerauthorJan 13.2007 — hi nightshift58,


here is the info about gd support from phpinfo()

GD Support enabled


GD Version bundled (2.0.22 compatible)


FreeType Support enabled


FreeType Linkage with freetype


GIF Read Support enabled


JPG Support enabled


PNG Support enabled


WBMP Support enabled


XBM Support enabled
Copy linkTweet thisAlerts:
@NightShift58Jan 13.2007 — GIF Read Support enabled[/QUOTE]
imagegif() creates the GIF file in filename from the image image. The image argument is the return from the imagecreate() or imagecreatefrom* function.[/quote]I read this as meaning that your PHP+GD version supports reading but not creating GIF formats - which is what you are trying to do.

An alternative would be to read in the GIF format but create the thumbnails in JPG, for example.
Copy linkTweet thisAlerts:
@bokehJan 13.2007 — GIF creation was disabled in version 1.6 and restored in version 2.0.28. What version of PHP are you running?
Copy linkTweet thisAlerts:
@NightShift58Jan 14.2007 — info about gd support from phpinfo()

GD Support enabled


GD Version bundled (2.0.22 compatible)


...

GIF Read Support enabled


...[/QUOTE]
See above...
Copy linkTweet thisAlerts:
@bokehJan 14.2007 — See above...[/QUOTE]I think you are replying to me. I saw he was using GD 2.0.22, I just wondered what version of PHP corresponds with that GD version.
Copy linkTweet thisAlerts:
@NightShift58Jan 14.2007 — I'm not sure but I think it doesn't matter since GIF creation support is GD-based and not native PHP. I believe that if the GD version was not compatible with the PHP version, PHP wouldn't have accepted it.

I think... I believe... Soft answers, I know...
Copy linkTweet thisAlerts:
@roshanjameerauthorJan 14.2007 — hi,

iam using php 4.3.6

thanks

mrjameer
Copy linkTweet thisAlerts:
@bokehJan 14.2007 — php 4.3.6[/QUOTE]If you update to a recent version (it's free ? ) this problem will be solved.
×

Success!

Help @roshanjameer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...