well i nearly done my dissertation now 2 more days of hard writting. Maybe another 40 pages or so

But I thought you might wanna check out my upload jpeg upload script cause i love it:
oh you can obviously upload several images at ones cause I am using an array for the html input: <input type='file' name='images[]' /> see here images is an array.
PHP Code:
<?php
session_start();
require_once('../image_fns.php');
$conn = db_connect();
while(list($key,$value) = each($_FILES[images][name])) //Loops through the uploaded array of Images
{
if(!empty($value))// this will check if any blank field is entered
{
if($_FILES[images][type][$key] == "image/jpeg") //This checks that the uploaded image is a jpeg file
{
$filename = $value; // filename stores the value
$userdir = $_SESSION['valid_user']; //The user who currently is logged in
$scrUserName = $userdir;
$uploaddir = 'images/'.$userdir.'/'; // upload directory path is set
@mkdir ($uploaddir,666); //Create directory
$randomnumber =rand(); //create random number
$srcFilename = $_FILES[images][name][$key]; //name of Image
$srcName = $randomnumber.$_FILES[images][name][$key]; //new name of image with random number in front of it
$uploadedfile = $uploaddir . $srcName; //the path and name of the uploaded file
$src = $uploadedfile;
if (copy($_FILES[images][tmp_name][$key], $uploadedfile)) // upload the file to the server and if successfull
{
$thuName = $srcFilename. "thumb.jpg"; //create thumbnail name
$desttemp = $uploadedfile . "thumb.jpg"; //thumbnail directory and name.
$dest = $desttemp;
//Set some variables for thumb creation
$maxWidth = "180";
$maxHeight = "180";
$quality = "90";
if (file_exists($src) && isset($dest)) // if the uploaded image was copied to the user image directory
{
// Returns information about a file path
$destInfo = pathInfo($dest);
// Put information into variables for DB insert
//Gets the image dimensions its an array
$srcSize = getImageSize($src);
//with and height
$srcHeight = $srcSize[1];
$srcWidth = $srcSize[0];
//todays date
$srcUploaddate = date("Y-m-d");
//Gets image size in bytes
$srcBytes = filesize($src);
$srcPath = $src;
$srcSize = getImageSize($src);
// $destSize[0] = width, $destSize[1] = height
$srcRatio = $srcSize[0] / $srcSize[1]; // width/height ratio
$destRatio = $maxWidth / $maxHeight;
//Maths for thumb creation
if ($destRatio > $srcRatio) {
$destSize[1] = $maxHeight;
$destSize[0] = $maxHeight * $srcRatio;
} else {
$destSize[0] = $maxWidth;
$destSize[1] = $maxWidth / $srcRatio;
}
//Create new truecolour image
$destImage = imagecreatetruecolor($destSize[0], $destSize[1]);
//Make sure the new image is antialiased
imageantialias($destImage, true);
//Created a new Image from the source
$srcImage = imagecreatefromjpeg($src);
// Copy and resize part of an image with resampling (create thumbnail)
imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0, $destSize[0], $destSize[1], $srcSize[0], $srcSize[1]);
// Output image to file
imagejpeg($destImage, $dest, $quality);
$thuPath = $dest;
$result = $conn->query("insert into Image (User_Name,Image_Size,Image_DisplayName,Image_Name,Image_Path,Image_UploadDate,Image_Thumbpath,Image_ThumbName,Image_Height,Image_Width)
values('$scrUserName',$srcBytes,'$srcFilename', '$srcName','$src','$srcUploaddate','$thuPath','$thuName',$srcHeight,$srcWidth)");
if (!$result)
echo 'Could not store images in database - please try again later.';
}
}
}
}
}
$_SESSION['UPLOADED']=true;
header("Location: http://localhost/dissertation/functions/image/index_new.php");
?>
__________________
/|\ Asus P5W DH Deluxe, Intel C2D E6600, 2GB Corsair XMS2-6400C4 DDR2, E-VGA GeForce 7800 GT, Creative X-Fi Extreme Music, 500GB Seagate 7200.10 SATA, Lian Li PC-V1100 Aluminum Case Black, etc.
http://germanjulian.com /|\