Where is the file selection widget in Drupal code?
The code to generate a field upload form element is in theme_file(). The code is very simple because all it does is to output an HTML file select form element. As explained in other answers, the files browsing dialog is provided by the web browser and, most of the time, re-uses the operating system native one.