or download this
# This will create the new file in the new location
until ( sysopen OUTFILE, UPLOAD_DIR . $uploadedfile, O_RDWR|O_CREAT|O_
+EXCL, 0777 ) {
$uploadedfile =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e;
$1 >= MAX_OPEN_TRIES and error( $grab_file, "Unable to save your f
+ile. File 1" );
}