Public Member Functions | List of all members
cppcms::widgets::file Class Reference

This class represents a file upload form entry. More...

#include <cppcms/form.h>

Inheritance diagram for cppcms::widgets::file:
cppcms::widgets::base_html_input cppcms::widgets::base_widget cppcms::base_form booster::noncopyable cppcms::form_flags

Public Member Functions

void non_empty ()
void limits (int min, int max)
std::pair< int, int > limits ()
void filename (booster::regex const &fn)
booster::regex filename ()
void validate_filename_charset (bool)
bool validate_filename_charset ()
booster::shared_ptr< http::filevalue ()
void mime (std::string const &)
void mime (booster::regex const &expr)
void add_valid_magic (std::string const &)
virtual void load (http::context &context)
virtual void render_value (form_context &context)
virtual bool validate ()
- Public Member Functions inherited from cppcms::widgets::base_html_input
 base_html_input (std::string const &type)
virtual ~base_html_input ()
virtual void render_input (form_context &context)
- Public Member Functions inherited from cppcms::widgets::base_widget
 base_widget ()
bool set ()
bool valid ()
std::string id ()
std::string name ()
locale::message message ()
bool has_message ()
locale::message error_message ()
bool has_error_message ()
locale::message help ()
bool has_help ()
bool disabled ()
void disabled (bool)
bool readonly ()
void readonly (bool)
std::string attributes_string ()
void set (bool)
void valid (bool)
void id (std::string)
void name (std::string)
void message (std::string)
void message (locale::message const &)
void error_message (std::string)
void error_message (locale::message const &)
void help (std::string)
void help (locale::message const &msg)
void attributes_string (std::string v)
virtual void render (form_context &context)
virtual void clear ()
virtual void render_attributes (form_context &context)
virtual void parent (base_form *subform)
virtual formparent ()
void pre_load (http::context &)

Additional Inherited Members

- Public Types inherited from cppcms::form_flags
enum  html_type { as_html = 0, as_xhtml = 1 }
enum  html_list_type {
  as_p = 0, as_table = 1, as_ul = 2, as_dl = 3,
  as_space = 4
enum  widget_part_type { first_part = 0, second_part = 1 }
- Protected Member Functions inherited from cppcms::widgets::base_widget
void auto_generate (form_context *context=0)

Detailed Description

This class represents a file upload form entry.

If the file was not uploaded, set() will be false and an attempt to access the member function value() will throw.

Member Function Documentation

void cppcms::widgets::file::add_valid_magic ( std::string const &  )

Add a string that represents a valid magic number that shoud exist on begging of file.

By default no tests are performed.

void cppcms::widgets::file::filename ( booster::regex const &  fn)

Set the filename validation pattern. For example ".*\\.(jpg|jpeg|png)".

Please, note that it is a good idea to check magic numbers as well and not rely on file name only.

See add_valid_magic() function

booster::regex cppcms::widgets::file::filename ( )

Get the regular expression for the filename validation.

void cppcms::widgets::file::limits ( int  min,
int  max 

Set the minimum and maximum limits for the file size. Note: max == -1 indicates that there is no maximum limit; min==0 indicates that there is no minimum limit.

std::pair<int,int> cppcms::widgets::file::limits ( )

Get the minimum and maximum size limits.

virtual void cppcms::widgets::file::load ( http::context context)

Load the form information from the provided http::context context. A user can call this function to load all information from the raw POST/GET data into the internal widget representation.

Implements cppcms::base_form.

void cppcms::widgets::file::mime ( std::string const &  )

Set the required file mime type.

void cppcms::widgets::file::mime ( booster::regex const &  expr)

Set the regular expression to validate the mime type.

void cppcms::widgets::file::non_empty ( )

Ensure that a file is uploaded (for the validation).

virtual void cppcms::widgets::file::render_value ( form_context context)

Write the actual value of the HTML tag. Derived classes must implement this.

Implements cppcms::widgets::base_html_input.

virtual bool cppcms::widgets::file::validate ( )

Validate the form. If not overridden, it sets the widget to valid.

Reimplemented from cppcms::widgets::base_widget.

void cppcms::widgets::file::validate_filename_charset ( bool  )

Validate or not the filename's charset. The default is true.

bool cppcms::widgets::file::validate_filename_charset ( )

Get the validation option for the filename's charset.

booster::shared_ptr<http::file> cppcms::widgets::file::value ( )

Get the uploaded file. This throws cppcms_error if set() == false, i.e. if no file was uploaded.

The documentation for this class was generated from the following file: