Might it be better to just use the mime type guesser always? Instead of setting $this->mimetype = $upload_ary['type'], use the mime type guesser to try and find the mimetype. This would clean up a lot of code.