add file upload support
improved slightly