CppCMS
Public Member Functions
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

List of all members.

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 ()

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.

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

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) [virtual]

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.

Set the regular expression to validate the mime type.

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

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

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 ( ) [virtual]

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

Reimplemented from cppcms::widgets::base_widget.

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

Get the validation option for the filename's charset.

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: