- Impact
- 0
Hey guys i am having a problem i am wondering if anyone can help i have made this whole entire site
http://www.almacenfurniture.com/site/index.php
then i realized crap i need to thumb all of the images.
right now i am storing all of these images in a db table in blobs and using another script to resize them i am wondering if anyone would know how to resize an image from a blob this is what i use to get the image
<?
include 'db.inc.php';
/////////// Application specfic defines for upload ///////////
// Database connection info, move to config //
define("DB_NAME", "");
define("DB_USER", "");
define("DB_PASS", "");
/////////// Application specfic defines for upload ///////////
// DB file table declartion //
define("DB_FILE_TABLE", "Images");
define("DB_FIELD_FILE_NAME", "Image_Name");
define("DB_FIELD_FILE_SIZE", "Image_size");
define("DB_FIELD_FILE_TYPE", "Image_Type");
define("DB_FIELD_FILE_DATA", "ImageData");
$DB = new cDB(DB_USER, DB_PASS, DB_NAME);
$ID = $_REQUEST['ID'];
$Results = $DB->Query("SELECT Image_Name, Image_Type, Image_size, ImageData FROM Images WHERE Image_ID = $ID");
$row = mysql_fetch_assoc($Results);
header("Content-Disposition: inline; filename= " . $row['Image_Name']);
header("Content-Length: " . $row['Image_size']);
header("Content-Type: " . $row['Image_Type']);
echo $row['ImageData'];
// header("Content-Disposition: attachment; filename=" . $result['attFilename']);
?>
and here is the db .php file
<?PHP
class cDB
{
// Members //
var $mUserName;
var $mPassword;
var $mLinks = array();
var $mLastLink;
///////////////////// Methods /////////////////////
/* Function: cDB
* Purpose: Constr
*/
function cDB($UserName, $Password, $Database)
{
// Open the connection //
$TempLink = mysql_connect('localhost', $UserName, $Password);
// Get the database //
if(mysql_select_db($Database, $TempLink))
{
$this->mLinks[$Database] = $TempLink;
$this->mLastLink = $TempLink;
}
else
$this->mLinks[$Database] = false;
}
function Query($SQL, $FileName = "N/A", $LineNumber = "N/A", $DataBase = '')
{
if(!empty($DataBase))
$this->mLastLink = $DataBase;
$Results = @mysql_query($SQL, $this->mLastLink);
if(mysql_error($this->mLastLink))
{
echo "<span style=\"align: center; color: #cc0000; width: 100%; font-size: 18pt;\">" . mysql_error($this->mLastLink) . " On Line $LineNumber.</span><hr>";
mail("[email protected]", "Error Message", "Error running the SQL query: $SQL.\nError message: " . mysql_error($this->mLastLink) . "\nFrom File: $FileName Line: $LineNumber.");
}
return($Results);
}
function Quote($Value)
{
if(get_magic_quotes_gpc())
$Value = stripslashes($Value);
if(!is_numeric($Value))
$Value = "'" . mysql_real_escape_string($Value) . "'";
return($Value);
}
function Insert($Table, $Values)
{
$SQL = "INSERT INTO
$Table
(";
$First = false;
foreach($Values AS $Key => $Value)
{
if(!$First)
{
$SQL .= $Key;
$First = true;
}
else
$SQL .= ",$Key";
$EntryValues[] = $Value;
}
$First = false;
$SQL .= ") VALUES(";
foreach($EntryValues AS $Value)
{
if(!$First)
{
$SQL .= $this->Quote($Value);
$First = true;
}
else
$SQL .= "," . $this->Quote($Value);
}
$SQL .= ")";
$this->Query($SQL);
}
}
those are how im managing the images it also works for files but i need a way to resize the image without just usein xhmtl or css.
if anyone has any clue i would be realy oprecative
http://www.almacenfurniture.com/site/index.php
then i realized crap i need to thumb all of the images.
right now i am storing all of these images in a db table in blobs and using another script to resize them i am wondering if anyone would know how to resize an image from a blob this is what i use to get the image
<?
include 'db.inc.php';
/////////// Application specfic defines for upload ///////////
// Database connection info, move to config //
define("DB_NAME", "");
define("DB_USER", "");
define("DB_PASS", "");
/////////// Application specfic defines for upload ///////////
// DB file table declartion //
define("DB_FILE_TABLE", "Images");
define("DB_FIELD_FILE_NAME", "Image_Name");
define("DB_FIELD_FILE_SIZE", "Image_size");
define("DB_FIELD_FILE_TYPE", "Image_Type");
define("DB_FIELD_FILE_DATA", "ImageData");
$DB = new cDB(DB_USER, DB_PASS, DB_NAME);
$ID = $_REQUEST['ID'];
$Results = $DB->Query("SELECT Image_Name, Image_Type, Image_size, ImageData FROM Images WHERE Image_ID = $ID");
$row = mysql_fetch_assoc($Results);
header("Content-Disposition: inline; filename= " . $row['Image_Name']);
header("Content-Length: " . $row['Image_size']);
header("Content-Type: " . $row['Image_Type']);
echo $row['ImageData'];
// header("Content-Disposition: attachment; filename=" . $result['attFilename']);
?>
and here is the db .php file
<?PHP
class cDB
{
// Members //
var $mUserName;
var $mPassword;
var $mLinks = array();
var $mLastLink;
///////////////////// Methods /////////////////////
/* Function: cDB
* Purpose: Constr
*/
function cDB($UserName, $Password, $Database)
{
// Open the connection //
$TempLink = mysql_connect('localhost', $UserName, $Password);
// Get the database //
if(mysql_select_db($Database, $TempLink))
{
$this->mLinks[$Database] = $TempLink;
$this->mLastLink = $TempLink;
}
else
$this->mLinks[$Database] = false;
}
function Query($SQL, $FileName = "N/A", $LineNumber = "N/A", $DataBase = '')
{
if(!empty($DataBase))
$this->mLastLink = $DataBase;
$Results = @mysql_query($SQL, $this->mLastLink);
if(mysql_error($this->mLastLink))
{
echo "<span style=\"align: center; color: #cc0000; width: 100%; font-size: 18pt;\">" . mysql_error($this->mLastLink) . " On Line $LineNumber.</span><hr>";
mail("[email protected]", "Error Message", "Error running the SQL query: $SQL.\nError message: " . mysql_error($this->mLastLink) . "\nFrom File: $FileName Line: $LineNumber.");
}
return($Results);
}
function Quote($Value)
{
if(get_magic_quotes_gpc())
$Value = stripslashes($Value);
if(!is_numeric($Value))
$Value = "'" . mysql_real_escape_string($Value) . "'";
return($Value);
}
function Insert($Table, $Values)
{
$SQL = "INSERT INTO
$Table
(";
$First = false;
foreach($Values AS $Key => $Value)
{
if(!$First)
{
$SQL .= $Key;
$First = true;
}
else
$SQL .= ",$Key";
$EntryValues[] = $Value;
}
$First = false;
$SQL .= ") VALUES(";
foreach($EntryValues AS $Value)
{
if(!$First)
{
$SQL .= $this->Quote($Value);
$First = true;
}
else
$SQL .= "," . $this->Quote($Value);
}
$SQL .= ")";
$this->Query($SQL);
}
}
those are how im managing the images it also works for files but i need a way to resize the image without just usein xhmtl or css.
if anyone has any clue i would be realy oprecative









