TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Problem creating and displaying image (http://www.talkphp.com/general/1335-problem-creating-displaying-image.html)

biggerboy 10-24-2007 07:57 PM

Problem creating and displaying image
 
I am using the code below, but instead of showing the new picture it just shows the url. Hopefully you can help. Thanks!

PHP Code:

// Lets make sure the id is safe
$id $_GET['id'];
$id sql_sant($id);

$query "SELECT * FROM images WHERE id= '$id'";
$result mysql_query($query) or die(mysql_error());

    if(
mysql_num_rows($result) == 0)
    {
    
$errormsg =    'Invalid ID, redirecting you back to homepage<br /> You will be redirected in 5 seconds, if you are not redirected <a href =" . $url . "> click here </a>';
header('Refresh: 5; url= index.php ');
exit();
    }
$line mysql_fetch_array($resultMYSQL_ASSOC);
$filename $line['realname'];
$filetype $line['type'];
$getfile './imgs/' $filename;

// Lets get the image to fit into our page
$width 600;
$height 600;

list(
$origwidth$origheight) = getimagesize($getfile);
if (
$width && ($width_orig $origheight)) {
   
$width = ($height $origheight) * $origwidth;
} else {
   
$height = ($width $origwidth) * $origheight;
}
$imagef imagecreatetruecolor($width,$height);

if (
$filetype == 'image/bmp')
{
$thumb imagecreatefromwbmp($getfile);
}

if (
$filetype == 'image/gif')
{
    
$thumb imagecreatefromgif($getfile);
}

if (
$filetype == 'image/png')
{

    
$thumb imagecreatefrompng($getfile);
}

if (
$filetype == 'image/jpeg')
{
$thumb imagecreatefromjpeg($getfile);
}

// ALMOST done :) Just put these babies where they need to be
imagecopyresampled($imagef$thumb0000$width$height$origwidth$origheight);

if (
$filetype == 'image/wbmp')
{
header('Content-type: image/vnd.wap.wbmp');
imagewbmp($imagef);

}

if (
$filetype == 'image/jpeg')
{
header('Content-type: image/jpeg');
imagejpeg($imagef);

}

if (
$filetype == 'image/png')
{
header('Content-type: image/png');
imagepng($imagef);

}

if (
$filetype == 'image/gif')
{
header('Content-type: image/gif');
imagegif($imagef);





All times are GMT. The time now is 12:43 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0