<?php
$dir = "/home/directory/where your/images/live/";
srand ((double) microtime() * 1000000);
# srand() initialized the random number function
$randnum = rand();
$randname="gev_".$randnum.".jpg";
$dirname = $dir.$randname;
#assigns unique, random name to image
# following section validates image size and type
if($userfile =='none'){
  die("There seems to be a problem with the file you tried to
upload. Please  click the Back button of your browser and try again");
}
$dimen = GetImageSize($userfile);
if($dimen[0] > 300){
   die("Your image is too wide. The maximum width for an image is 300
pixels. Please try again. ");
}
if($dimen[1] >300){
   die("Your image is too long. The maximum length for an image is 300
pixels. Please try again. ");
}
# checks mime type for correct files. 
if($userfile_type!='image/pjpeg'&&$userfile_type!='image/gif'&&$userfile_type!='image/jpeg'&&$userfile_type!='image/x-png'){
   die("You uploaded a file that is not a .gif, .png, or .jpg
format. Please try again.");
}
if($userfile_size > 50000){
   die("You tried to upload a file that is too large. The maximum size
for a file is 50KiloBytes. Please try again.");
}
#if all of the above succeeds:
copy($userfile,$dirname);
?>