$filekey = $cgi->param("doc_file"); unlink($filekey) if -e $pubFile_path$filekey; if ($filekey) { if ($filekey =~ /([^\/\\]+)$/) { $filename = $1; ($ext) = $filename =~ /(\.\w+)$/; } else { return "You attempted to upload $filekey that isn't properly formatted. Please rename the file on your computer, and attempt to upload it again. Files may not have forward or backward slashes in their names. Also, they may not be prefixed with one (or more) periods."; } $path = $pubFile_path . "/" . $count . $ext; open(OUTFILE, ">$path") or &script_err("Unable to open $path \nReason: $!");; binmode(OUTFILE); while ($bytes = read($filekey,$buffer,1024)) { $totalbytes += $bytes; print OUTFILE $buffer; } close(OUTFILE); }