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.
3 Answers
The dialog box is a feature of your browser. The server sends HTML code looking something like
<input type="file">
Most browsers render this by providing a text input field and a Browse button.
-
I have searched through core trying to find an instance of this call in association with the Browse button mentioned in my question to confirm how to incorporate it into a form without success. I have asked a new question seeking an answer. Can you help?– AshlarCommented Dec 1, 2011 at 15:53
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.
You are confusing client side and server side. The code you are seeking is internal to the browser (the client); it is not within Drupal (the server).