Re: [Cppcms-users] undefined reference to `cppcms::widgets::file::filename(booster::regex const&)'
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2010-09-13 10:01:31
|
> BTW, there are some better tests for checking file type: mime() type and >add_valid_magic() where the last is the best >one. > > > >Thank you for the enlightenment! According to > > >http://www.garykessler.net/library/file_sigs.html > > >, the jpeg magic number is "FF D8 FF E0 xx xx 4A 46 49 46 00" and the png one is > >"89 50 4E 47 0D 0A 1A 0A". > > > >Member function > > >void cppcms::widgets::file::add_valid_magic(std::string const &) > > >expects std::string as the argument. If I accept both jpeg and png files, what >std::string should I pass to add_valid_magic? You should call add_valid_magic twice and for one provide a valid magic: For jpeg, is is enough to give "\xFF\xD8\xFF" (see more detailed description in the link you had given) and for PNG "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" > > >This raises another question: It is server's responsibility rather than browsers > >to perform the validation triggered by add_valid_magic, isn't it? Of course it is the server side check, quite simple - test of file begins with this string - that's it. > If it is, will > cppcms automatically do the validation? Yes, when you call your_form.validate() (as you usually do for forms) you'll get the validation result. Each widget has its own set of parameters to validate. > If it is programmer's job, a snippet of > validation example code will be much appreciated. > See forms example (you had probably seen it) and refer to each widget reference to see validation options: http://cppcms.sourceforge.net/cppcms_ref_v0_99/namespacecppcms_1_1widgets.html Artyom |