How to Upload a File With WordPress’ Secret Native Functions

Like any good CMS, WordPress offers a bunch of functions, some of which may be hidden under the hood. For example, did you know that WordPress provides dedicated functions for uploading files, figuring out the file type and adding attachments?