Results 1 to 1 of 1
Thread: thumbnail problem...
-
November 1st, 2005, 06:14 PM #1134Lord of The Dead
poststhumbnail problem...
here is my code. it does exactly what i want it to do...upload an image and then create a thumbnail. only problem is...when i create the thumbnail. its not so much as a thumbnail as it is a small black picture. because the entire thing is just black. not a smaller version of the picture. any help please?
PHP Code:if ($_FILES['file']['type'] == "image/gif" or $_FILES['file']['type'] == 'image/jpeg' or $_FILES['file']['type'] == 'image/pjpeg'){
$target_path = './data/images/uploads/';
$thumb_path = $target_path."thumbs/";
$target_path = $target_path . basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['file']['name']). " has been uploaded<br>";
} else{
die("There was an error uploading the file, please try again!");
}
} else {
die("File must be an image<br>");
}
createthumb($target_path,$thumb_path.basename( $_FILES['file']['name']),59,59);
the createthumb function:
PHP Code:function createthumb($name,$filename,$new_w,$new_h)
{
$size = getimagesize($name);
$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=$size[0];
$old_y=$size[1];
if ($old_x > $old_y)
{
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y)
{
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y)
{
$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);
}
Last edited by eyeofthestorm; November 1st, 2005 at 06:21 PM.
Similar Threads
-
URGENT: Problem With Javascript Popup menu and Flash Movie
By clzz in forum Flash IDEReplies: 1Last Post: April 14th, 2006, 04:14 PM -
Importing Large Sized Video Problem
By hershy in forum Flash IDEReplies: 5Last Post: March 11th, 2006, 03:02 PM -
Problem in visibility of macromedia help files in XP
By rajesh_pila in forum Flash IDEReplies: 1Last Post: August 2nd, 2005, 03:18 PM -
Help needed with weird loadVars problem
By Silenus in forum ActionScript 2 (and Earlier)Replies: 3Last Post: May 17th, 2005, 08:56 AM -
thumbnail slideshow with if statements
By seanc in forum Flash IDEReplies: 1Last Post: February 19th, 2004, 03:07 PM

Reply With Quote

Bookmarks