class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
if(strtolower(substr(PHP_OS, 0, 3)) === 'win') { if (substr($server_path, -1, 1) != '\\') $server_path = $server_path . '\\'; } else { if (substr($server_path, -1, 1) != '/') $server_path = $server_path . '/'; }