ryan010101
Technical User
I purchased a shopping cart solution called XCart which uses Smarty templates and MySQL. The way it handles images of products is to store the actual image in the database. This doesn't work for me so I created a field in the products table called "imageName" and I want to just reference that field name when it displays the image (so it builds the img tag). The problem is the template uses a file called "image.php" to display all images. This file is what is actually displaying the image. This is the code:
require "./smarty.php";
require "./config.php";
$result=db_query("select image,image_type from thumbnails where productid='$productid'"
if(db_num_rows($result)) list($image,$image_type)=db_fetch_row($result);
db_free_result($result);
if(!empty($image)) {
header("Content-type: $image_type"
echo $image;
}
else
{
$fi=fopen($default_image,"rb"
$image=fread($fi,filesize($default_image));
header("Content-type: image/gif"
echo $image;
}
So what I want to do is load the image from a directory instead of loading it from a database and then return it. Is that possible?
require "./smarty.php";
require "./config.php";
$result=db_query("select image,image_type from thumbnails where productid='$productid'"
if(db_num_rows($result)) list($image,$image_type)=db_fetch_row($result);
db_free_result($result);
if(!empty($image)) {
header("Content-type: $image_type"
echo $image;
}
else
{
$fi=fopen($default_image,"rb"
$image=fread($fi,filesize($default_image));
header("Content-type: image/gif"
echo $image;
}
So what I want to do is load the image from a directory instead of loading it from a database and then return it. Is that possible?