...

View Full Version : Showing an image



Ludatha
11-29-2008, 05:29 PM
Can someone help me display an image, I don't know how


<?php
// Work around the Flash Player Cookie Bug
if (isset($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
}

if(isset($_GET['id']) && isset($_GET['type'])){
mysql_connect('localhost', 'root', '');
mysql_select_db('ludatha_base');

$id = $_GET['id'];

$sql = "SELECT * FROM images WHERE code = '$id'";

$result = mysql_query($sql);

$linkege=mysql_fetch_array($result);

if($_GET['type'] == 'pic'){
$file = 'upload/1/pictures/' . $linkege['file'];
}else{
$file = 'upload/1/pictures/' . $linkege['thumb'];
}

header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=' . $file . '.jpg');
echo $file;
}
?>

$linkege['file'] gets the file name of the image

Thanks in advance!

Fou-Lu
11-29-2008, 05:42 PM
You got to read the file and print out the contents of it:


if (false !== ($fh = fopen($file, 'rb')))
{
if (false !== ($fr = @fread($fh, filesize($file))))
{
header('Content-type: image/jpeg');
echo $fr;
}
}

Try something like this in place of what you have at the end.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum