Im trying to build a mySQL database for images that displays images along side a current upload facility. Therefore create a duel upload facility. The upload system i use is a modified version of the standard download module that i got off the phpnuke website some time ago - and i have not seen it since anywhere! The rar file was named 91.rar. The end game is to provide upload for programs or anything else - with the ability to display picture along the catalogue listing. There is various articles with code which describe how to create a binary longblob picture database, however im having problems integrating it into the upload feature and catalogue listing and search........is there a simple way to modify the current phpnuke module to enable this .......i fear im making this very hard for myself when it doesnt need to be!!!!
This is the kinda code im trying to integrate http://www.weberdev.com/ViewArticle.php3?ArticleID=3
and then to display as thumbnails with code such as this
1) MySQL Table
To create thumbnails online out of MySQL-BLOB's i'm using the following table-
structure:
CREATE TABLE images (
PicNum int(11) NOT NULL auto_increment,
file_date date default NULL,
file_title varchar(50) default NULL,
file_text varchar(255) default NULL,
image longblob,
file_type varchar(50) default NULL,
PRIMARY KEY (PicNum),
UNIQUE KEY id (PicNum)
) TYPE=MyISAM;
The image-data itself is stored in image, the image-Type in file_type.
The other fields contain additional information about the file - these fields are
optional.
There are a lot of tutorials and samples how to get images and other files uploaded
and
stored into a BLOB-field, so i will not describe this here.
2) getthumb.php file
You need to have gd-library installed!!!
You will need a php-file which will be used everytime you want to create a thumbnail.
This file is called with an url-argument named ID (see 3)).
<?php
// Place the code to connect your Database here
// DATABASE CONNECTION
global $id;
// Check if ID exists
if(!is_numeric($id)) die("No image with the ID: ".$id);
// Get data from database
$dbQuery = "SELECT image, file_type ";
$dbQuery .= "FROM images ";
$dbQuery .= "WHERE PicNum = $id ";
$dbQuery .= "LIMIT 1";
$result = mysql_query($dbQuery);
// read imagetype + -data from database
if(mysql_num_rows($result) == 1) {
$fileType = mysql_result($result, 0, "file_type");
$fileContent = mysql_result($result, 0, "image");
header("Content-type: $fileType");
// get originalsize of image
$im = imagecreatefromstring($fileContent);
$width = imagesx($im);
$height = imagesy($im);
// Set thumbnail-width to 100 pixel
$imgw = 100;
// calculate thumbnail-height from given width to maintain aspect ratio
$imgh = $height / $width * $imgw;
// create new image using thumbnail-size
$thumb=ImageCreate($imgw,$imgh);
// copy original image to thumbnail
ImageCopyResized($thumb,$im,0,0,0,0,$imgw,$imgh,ImageSX($im),ImageSY($im));
// show thumbnail on screen
$out = ImagejpeG($thumb);
print($out);
// clean memory
imagedestroy ($im);
imagedestroy ($thumb);
}
?>
3) Calling getthumb.php from any other file
To show a thumbnail from an image (for example with PicNum = 17) you just have to
place the
following code in your page:
<img src='getthumb.php?id=17>
I found this on a website..........i forget where......and do not wish to offend by posting .......so sorry !