Where is the file selection widget in Drupal code? If a content type has an image field then when the user creates new content, he is present with an image section on the form with a widget to "Browse" for a file.  Clicking it provides a pop-up window standard dialog box for selecting a file.  I would like to examine how this works to use it in a custom module, but cannot locate the code in the core modules.
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.