TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-24-2007, 07:57 PM   #1 (permalink)
The Visitor
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
biggerboy is on a distinguished road
Default 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);


biggerboy is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:58 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design