htmlInputFile
File input class
[Previous] [Main] [Next]


Description
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.  
 
Declaration
#include <dcmicro/htmlpp/inputfil.h>  
 
Hierarchy
htmlinputfile.gif  
 
See Also
htmlForm, htmlCgi, htmlInputText  
 
Related Constants/Definitions
None.  
 
Constructors
htmlInputFile()  
Constructs an empty object.  
 
htmlInputFile(const String& name,  
   int display_length = 0,  
   int max_length = 0 )  
Constructs an empty file input object, using the specified name and dimensions for the filename field.  
 
htmlInputFile(const String& name,  
   const String& value,  
   int display_length = 0,  
   int max_length = 0 )  
Constructs an object using the specified name and dimensions for the filename field, populating it's initial value with value.  
 
Destructors
virtual ~htmlInputFile()  
Destroys the object.  
 
Member Methods
AccepthtmlInputFile& Accept( const String& media_types )  
Set the list of allowed media types or type patterns for the input to media_types, and returns a reference to the object.  
 
AcceptString Accept() const  
Returns the list of allowed media types or type patterns for the input, or an empty string if not set.  
 
ClonehtmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Example
 
See the example in Tutorial:Forms:File Uploads  
 


©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.