Here is a script I use.
It stores the pictures in a folder called pics
Creates a thumbnail and stores that in a folder called thumbs
then stores the info in a database.
Just make the appropriate changes
<?php
$file_dir = "/home/litebear/public_html/effie/gallery/pics";
foreach($_FILES as $file_name => $file_array) {
$var1 = $file_array['tmp_name'];
$var2 = $file_array['name'];
$var3 = $file_dir . "/" . $file_array[name];
if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'],
"$file_dir/$file_array[name]") or die ("could not copy");
}
}
$comments = trim($_POST['comments']);
###################
#
# Define the thumbnail
# creation function
#
###################
function thumbnail($image_path,$thumb_path,$image_name,$thumb_width)
{
$src_img = imagecreatefromjpeg("$image_path/$image_name");
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = $thumb_width;
$diff=$origw/$new_w;
$percent_diff = $new_w/$origw;
$new_h = $origh * $percent_diff;
$job = 3;
if ($origw > $origh) {
$job = 1;
}
if ($origw < $origh) {
$job = 2;
}
SWITCH ($job) {
case 1:
$new_w = 100;
$new_h = $origh * (100/$origw);
break;
case 2:
$new_h = 100;
$new_w = $origw * (100/$origh);
break;
case 3:
$new_w = 100;
$new_h = 100;
break;
}
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "$thumb_path/$image_name",85);
return true;
}
##################
#
# end of thumbnail function
#
##################
#####################
#
# set the max width for the thumbnail
# and create the thumbnail
#
#####################
$what_width = 100;
$file_dir2 = "/home/litebear/public_html/effie/gallery/thumbs";
thumbnail($file_dir,$file_dir2,$var2,$what_width);
###################
#
# Calculate the upload date
#
###################
$ts = time(); //gets current server date as a timestamp
$tsgmt = gmmktime(); //gets timestamp for GMT
// date dst starts in the US
$start_dst = "20040404";
// date dst ends in the US
$end_dst = "20041031";
// set local offset from gmt
$est_off_set = 18000; // offset for Eastern Standard Time
// set local timestamps
$ts_est = $tsgmt - $est_off_set;
// adjust time stamps for DST
$est_date = date("Ymd", $ts_est);
if ($est_date >= $start_dst && $est_date <= $end_dst) { $ts_est = $ts_est + 3600; }
##################
#
# end date calc
#
###################
$fullpic = $var2;
$thumbpic = $var2;
$uploaddate = $est_date;
include ('db.php');
$sql = "INSERT INTO our_fam_gallery (comments, fullpic, thumbpic, uploaddate) VALUES ('$comments', '$fullpic', '$thumbpic', '$uploaddate')";
$result = mysql_query($sql);
?>
Your picture <B><I> <? echo $var2; ?></b></i> has been uploaded <br>and a thumbnail created.<br>
<IMG SRC = "<?PHP echo "./thumbs/" . $thumbpic; ?>"><br>
the comments were: <br>
<B><?PHP echo $comments; ?></b><br><br>
The load date is: <B><?PHP echo $uploaddate; ?></b><br><br>
You may upload another picture by clicking the <b>Add</b> button below, <br>
or peruse the gallery by clicking the <B>View</b> button, <br>
or you may choose any of the menu items from your left.
<?PHP
?>
Lite...
BTW for non-windows systems (most likely your host) use the forward slash "/" to define urls, not the "\"