Solution:
You can check wp_check_filetype_and_ext
to check the filetype and proper extension.
Reference: https://codex.wordpress.org/Function_Reference/wp_check_filetype_and_ext
You can use wp_handle_upload
hook to process uploaded file, similar to: https://wordpress.stackexchange.com/a/38585