Here are the functions that my company uses to upload and validate ppictures, they problably have gotten them in an web page. They usually don't delete the files, they keep them there and can upload other/the same file over that one, replacing it...
function validate_upload($the_file, $my_max_file_size, $image_min_width, $image_min_height,
$image_max_width, $image_max_height, $allowed_types, $the_file_type,
$registered_types) {
if ($the_file == '') { # do we even have a file?
$error .= "Pick a foto.";
} else { # check if we are allowed to upload this file_type
if (!in_array($the_file_type,$allowed_types)) {
$error .= "Error. The image must be in the following file types:";
while ($type = current($allowed_types)) {
$error .= "\n<li>" . $registered_types[$type] . " (" . $type . "

</li>";
next($allowed_types);
}
}
if (ereg("image",$the_file_type) && (in_array($the_file_type,$allowed_types))) {
$size = GetImageSize($the_file);
list($foo,$width,$bar,$height) = explode("\"",$size[3]);
if ($width > $image_max_width) {
$error .= "Error: The imge size can't be higher than " . $image_max_width . " pixels width." . "<br>";
}
if ($height > $image_max_height) {
$error .= "Error: The image can't be more than " . $image_max_height . " Pixels de height";
}
if ($image_min_height > 0) {
if ($height < $image_min_height ) {
$error .= "Error: The image can't be less than " . $image_max_height . " pixels height";
}
}
if ($image_min_width > 0) {
if ($width < $image_min_width ) {
$error .= "Error: The image can't be less than " . $image_max_width . " Pixels width";
}
}
}
if ($error) {
return $error;
} else {
return false;
}
}
} # END validate_upload
# --
function upload($the_file, $the_path, $the_file_name, $my_max_file_size, $image_min_width,
$image_min_height, $image_max_width, $image_max_height, $allowed_types,
$the_file_type, $registered_types) {
$error = validate_upload($the_file, $my_max_file_size, $image_min_width, $image_min_height,
$image_max_width, $image_max_height, $allowed_types, $the_file_type,
$registered_types);
if ($error) {
return $error;
} else { # cool, we can continue
if (!@copy($the_file, $the_path . "/" . $the_file_name)) {
$tam = $my_max_file_size/1024;
return "Couldn't refresh the image. max $tam Kb.";
}
}
} # END upload
Hope it may be usefull...