Jump to content

createthumb()... gd prob?


MikeDXUNL

Recommended Posts

I am in ... mysite.com/sub/adm/

 

and uploading to mysite.com/sub/wallpapers/

-----

 

well my GD is all a-go. but... for some reason, the function is not working properly.

 

In a form, I choose a category.. lets say 'pets' and then browse for the wall...

 

so then it checks the image variants and if everything is cool.. it uploads it and moves it

 

 

uploadwall.php:

<?php
//Define Variables
####################################
$maxfilesize = 2000000;
####################################


// Check if file was uploaded
if (!is_uploaded_file($_FILES['wallpaper']['tmp_name'])) {
    $error = "you didn't select a file to upload.<br />";
// Check if file is < size range
} else {
    if ($_FILES['wallpaper']['size'] > $maxfilesize) {
        $error = "your image file was too large.<br />";
        unlink($_FILES['wallpaper']['tmp_name']);
    } else {
// Check if acceptable file extension
        $ext = strrchr($_FILES['wallpaper']['name'], ".");
        if ($ext != ".gif" AND $ext != ".jpg" AND $ext != ".jpeg" AND $ext != ".bmp" AND $ext != ".GIF" AND $ext != ".JPG" AND $ext != ".JPEG" AND $ext != ".BMP") {
            $error = "your file was an unacceptable type.<br />";
            unlink($_FILES['wallpaper']['tmp_name']);
// Upload and Replace photo
        } else {

$var_x = randomkeys(1);

            $newname =  $var_x."_".$up_catname."_".$_FILES['wallpaper']['size'].$ext;
            
            
            $newname_th1 = $var_x."_".$up_catname."_".$_FILES['wallpaper']['size']."_th1".$ext;
            
          
            $newname_th2 = $var_x."_".$up_catname."_".$_FILES['wallpaper']['size']."_th2".$ext;
            
            
            move_uploaded_file($_FILES['wallpaper']['tmp_name'],"../wallpapers/".$up_catname."/".$newname);
            mysql_query("INSERT INTO wallpaper (wallname, walldesc, catname, author, date, total_votes, total_value) VALUES ('$up_wallname', '$up_walldesc', '$up_catname', '$username', '$date', '0', '0')") or die (mysql_error());
            
               createthumb('../wallpapers/'.$up_catname.'/'.$newname.'', '../wallpapers/'.$up_catname.'/thumb1/'.$newname_th1.'', 160, 120);
               
                            createthumb('../wallpapers/'.$up_catname.'/'.$newname.'', '../wallpapers/'.$up_catname.'/thumb2/'.$newname_th2.'', 320, 240);
      	    }
    	}
}
?>

 

 

--- $up_catname would be equal to 'pets' and size to whatever the image size is...

 

here is

 

createthumb()

<?php
function createthumb($name,$filename,$new_w,$new_h)
{
$system = explode(".",$name);
if (preg_match("/jpg|jpeg/",$system[1])){$src_img = imagecreatefromjpeg($name);}
if (preg_match("/png/",$system[1])){$src_img = imagecreatefrompng($name);}
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);

	$thumb_w = $new_w;
	$thumb_h = $new_h;

$dst_img = ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);

if (preg_match("/png/",$system[1]))
{
	imagepng($dst_img,$filename); 
} else {
	imagejpeg($dst_img,$filename); 
}

imagedestroy($dst_img); 
imagedestroy($src_img); 
}
?>

 

 

the error i am getting is:

 

Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 84

 

Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 85

 

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 91

 

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 101

 

Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 84

 

Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 85

 

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 91

 

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\vgwalls\incl\functions.php on line 101

 

 

please, if someone could help or suggest reasons as to why this is happening. it would be greatly appreciated :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.