Im trying to add GD support into my PHP script , so that when my users upload a file , it takes the file , and makes a thumbnail out of it , and stores it in the images directory along with the file.
Here's where im at so far , after this executes the screen goes blank , if i take the GD code out , the image uploads just fine ... theirs alot more code , but this is what i beleive is the problem ..
if(!$upload_image_error)
{
$sql = "
select
total_files
from
$tb_users
where
id = '$_SESSION[userid]'
";
$query = mysql_query($sql) or die(mysql_error());
$total = mysql_result($query, 0, "total_files");
$number = $total + 1;
$main_picture= $_POST['pic_type'];
if($total && $main_picture=="y") {
$number=1;
}
$file_name = $_SESSION['userid'] . "_$number." . $the_file_ext;
if(isset($_POST['overwrite']))
{
if(copy($_FILES['the_file']['tmp_name'], $image_path . "/" . $file_name))
{
/////////////////////////////////////////////MAKE GD 2 THUMBNAIL/////////////////////////////////////////
// Let's get the Thumbnail size
$photos_uploaded = $_FILES['the_file'];
$size = GetImageSize( $image_path."/".$file_name );
if($size[0] > $size[1])
{
$thumbnail_width = 100;
$thumbnail_height = (int)(100 * $size[1] / $size[0]);
}
else
{
$thumbnail_width = (int)(100 * $size[0] / $size[1]);
$thumbnail_height = 100;
}
// Build Thumbnail with GD 2.x.x
$function_suffix = $gd_function_suffix[$filetype];
$function_to_read = 'ImageCreateFrom' . $function_suffix;
$function_to_write = 'Image' . $function_suffix;
// Read the source file
$source_handle = $function_to_read($image_path . '/' . $file_name);
if ($source_handle) {
// Let's create a blank image for the thumbnail
$destination_handle =
ImageCreateTrueColor($thumbnail_width, $thumbnail_height);
// Now we resize it
ImageCopyResampled($destination_handle, $source_handle,
0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]);
}
// Let's save the thumbnail
$function_to_write($destination_handle, $image_path . '/tb_' . $file_name);
ImageDestroy($destination_handle );
//////////////////////////////////////////////////////////////////////////////////////////////////////