Code:
$new_height=60;
$new_width=80;
$allowed_types = array(
'image/pjpeg',
'image/gif',
'image/png',
'image/jpeg');
if(in_array($_FILES['userfile']['type'], $allowed_types))
{
copy ($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']) or die ("Could not copy");
$imagefile=$_FILES['userfile']['name'];
list($width, $height) = getimagesize($_FILES['userfile']['name']);
$image_p = imagecreatetruecolor($new_width,$new_height);
if ($_FILES['userfile']['type'] == "image/gif")
{
$img = @imagecreatefromgif($imagefile);
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$thename=$_FILES['userfile']['name'];
$thenames="thumb$thename";
$location="$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['userfile']['name'];
$thenames="thumb$thename";
$location="$thenames";
imagejpeg($image_p,$location, 100);
}
}
$new_height=60;
$new_width=80;
$allowed_types = array(
'image/pjpeg',
'image/gif',
'image/png',
'image/jpeg');
if(in_array($_FILES['userfile']['type'], $allowed_types))
{
copy ($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']) or die ("Could not copy");
$imagefile=$_FILES['userfile']['name'];
list($width, $height) = getimagesize($_FILES['userfile']['name']);
$image_p = imagecreatetruecolor($new_width,$new_height);
if ($_FILES['userfile']['type'] == "image/gif")
{
$img = @imagecreatefromgif($imagefile);
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$thename=$_FILES['userfile']['name'];
$thenames="thumb$thename";
$location="$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['userfile']['name'];
$thenames="thumb$thename";
$location="$thenames";
imagejpeg($image_p,$location, 100);
}
}
To sve lepo sljaka na localhostu, nemam zamerke :) , medjutim kada kod postavim na net, thumb se uopste ne kreira, vec se uplouaduje samo originalna slika. ?!?
Ja kod sebe gde sve lepo radi imam PHP Version 5.2.0 i GD Version bundled (2.0.28 compatible),
dok je kod provajdera PHP Version 4.3.2 i GD Version bundled (2.0.12 compatible)
U cemu je problem.
Ako hvatas male ribice, mozes da ostanes u plicaku, za veliku ribu, moras da zagazis dublje !