Ok, i am stumped.. I have it so that i can store the information into the database.. Thanks for your suggestion on that.. i have another question for ya. I am trying to run a image resize script that i found. The script run great if i run it from the location of the images that i am resizing, but if i attempt to run it from another location it erros out and says that it can not find the files.. Here is the script that i am trying to use followed by my code to invoke.. Any help would be appreciated..
<?php
/*
Version 1.0 Created by: Ryan Stemkoski
Questions or comments: ryan@ipowerplant.com
Visit us on the web at: http://www.ipowerplant.com
Purpose: This script can be used to resize one or more images. It will save the file to a directory and output the path to that directory which you
can display or write to a databse.
TO USE, SET:
$filename = image to be resized
$newfilename = added to filename to for each use to keep from overwriting images created example thumbnail_$filename is how it will be saved.
$path = where the image should be stored and accessed.
$newwidth = resized width could be larger or smaller
$newheight = resized height could be larger or smaller
SAMPLE OF FUNCTION: makeimage('image.jpg','fullimage_','imgs/',250,250)
Include the file containing the function in your document and simply call the function with the correct parameters and your image will be resized.
*/
//IMAGE RESIZE FUNCTION FOLLOW ABOVE DIRECTIONS
function makeimage($filename,$newfilename,$path,$newwidth,$newheight) {
//SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER . )
$image_type = strstr($filename, '.');
//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
case '.jpg':
$source = imagecreatefromjpeg($filename);
break;
case '.png':
$source = imagecreatefrompng($filename);
break;
case '.gif':
$source = imagecreatefromgif($filename);
break;
default:
echo("Error Invalid Image Type");
die;
break;
}
//CREATES THE NAME OF THE SAVED FILE
$file = $newfilename . $filename;
//CREATES THE PATH TO THE SAVED FILE
$fullpath = $path . $file;
//FINDS SIZE OF THE OLD FILE
list($width, $height) = getimagesize($filename);
//CREATES IMAGE WITH NEW SIZES
$thumb = imagecreatetruecolor($newwidth, $newheight);
//RESIZES OLD IMAGE TO NEW SIZES
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//SAVES IMAGE AND SETS QUALITY || NUMERICAL VALUE = QUALITY ON SCALE OF 1-100
imagejpeg($thumb, $fullpath, 100);
//CREATING FILENAME TO WRITE TO DATABSE
$filepath = $fullpath;
//RETURNS FULL FILEPATH OF IMAGE ENDS FUNCTION
return $filepath;
}
?>
<?
require 'dbcon.php';
include("uploads/resize.php");
$count=count($_FILES['test']['name']);
$i=0;
echo " This is the $count";
// ==============
// Configuration
// ==============
$allowed_ext = "jpg"; // These are the allowed extensions of the files that are uploaded
$max_size = "50000"; // 50000 is the same as 50kb
$max_height = "600"; // This is in pixels
$max_width = "900"; // This is in pixels
// changed the actual path to "pathtodirectory" since im posting this on a public forum
$uploaddir = "/home/pathtodirectory/pathtodirectory/test/uploads"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777!
while($i < $count) {
$check = $_FILES['test']['size'][$i];
if($check !='0') //if a file was uploaded in this field
{
echo "<br>start run $i";
// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILES['test']['tmp_name'][$i]);
if($width > $max_width || $height > $max_height)
{
print "File height and/or width are too big!";
exit;
}
}
// ==============
// Upload Part
// ==============
if(is_uploaded_file($_FILES['test']['tmp_name'][$i]))
{
move_uploaded_file($_FILES['test']['tmp_name'][$i],$uploaddir.'/'.$_FILES['test']['name'][$i]);
}
$images[] = $_FILES['test']['name'][$i];
$name=$_FILES['test']['name'][$i];
echo " <bR>the name of the file about to be resized $name <br>";
makeimage($name,'thumbnail_','/test/uploads/',150,100);
echo "<br>end run $i";
} // ends the if a file was uploaded loop
else{
}
$i++;
} //ends while loop
//adds information to the database
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die ("Unable to connect to database");
$query = "INSERT INTO stuff SET image0='$images[0]', image1='$images[1]', image2='$images[2]', image3='$images[3]', image4='$images[4]',image5='$images[5]',image6='$images[6]', image7='$images[7]', image8='$images[8]', image9='$images[9]', image10='$images[10]', image11='$images[11]'";
mysql_query($query) or die(mysql_error());
echo "done";
?>