| htmlInputFile encapsulates the <INPUT TYPE="FILE"></INPUT> tags. This class implements form-based file upload capabilities as described in RFC1867. It is used to create a text input control for a filename on a form, that includes a "Browse..." button next to the text input control, allowing users to select and upload a file from their system. htmlInputFile is derived from htmlInputText, so all the same methods from that class can be used.
|
|
|
| When the form is submitted, the content of the specified file is sent to the server along with the other form data. Note that this tag is only supported by NetScape Navigator 2.0 and later, and Microsoft Internet Explorer 3.02 and later.
|
|
|
| The HTML specification requires that forms containing file upload controls use the encoding type "multipart/form-data". Unless the htmlForm::Encode() method is called manually, the htmlForm class will automatically set the correct encoding type whenever an htmlInputFile object is added, relieving you of that concern.
|
|
|
| When receiving uploaded files from forms, the htmlCgi class will automatically capture and save the file contents in a temporary file. In such cases, the name of the form field will not appear in the CGI name/value list. Instead, htmlCgi adds two name/value pairs for each file element received.The names of these values are based on the form field name from which they originated, with the addition of a dot followed the word "local" or "remote". They are accessible via the htmlCgi::Value() method.
|
|
|
| For example, if the field name representing the file upload button on the form were named "file", htmlCgi would generate name/value pairs using the following two names:
|
| file.local
|
| file.remote
|
|
|
| The value associated with the ".local" suffix represents the name of the local temporary file used to store the received file contents. The value associated with the ".remote" suffix represents the remote (on the browser) name of the file that the user selected on their system.
|
|
|
| It is the responsibility of the developer to use or delete temporary files once received.
|
|
|
| |