It depends how you are using selenium (framework & etc) But basic is when you are calling selenium to perform file upload you are making HTTP POST request to selenium remote server and sending local file as it's parameter.
Adds:
If you check Python framework here - https://github.com/SeleniumHQ/selenium/blob/fec87ea8c2a4704bd1e7bcddf9a98e400823ef4e/py/selenium/webdriver/remote/webelement.py
In "local" code you write path to file in send_keys function
if this function understand that it is file
local_file = self.parent.file_detector.is_local_file(*value)
it will call def _upload in same file
it will zipped and encode it,
and pass to next function
return self._execute(Command.UPLOAD_FILE, {'file': content})['value']
In next file - you can find command which _upload executes
https://github.com/SeleniumHQ/selenium/blob/fec87ea8c2a4704bd1e7bcddf9a98e400823ef4e/py/selenium/webdriver/remote/remote_connection.py
def execute(self, command, params): Command.UPLOAD_FILE: ('POST', "/session/$sessionId/file")
sendKeysis called with a valid file path on an<input>DOM element. But depending on the client, you may have to setup a file detector.