Re: [Cppcms-users] cppcms::widgets::file is always not set
Brought to you by:
artyom-beilis
|
From: Artyom <art...@ya...> - 2010-10-31 10:19:57
|
Two points:
1. Make sure you add the file widget to the form by using:
*this + uploaded_file
or
add(uploaded_file)
2. Make sure you use enctype="multipart/form-data" in your form. i.e.
<form method="post" action="URL" enctype="multipart/form-data" >
<% form as_p info %>
</form>
Because you can't upload file using regular "post" using
default encoding "application/x-www-form-urlencoded"
Artyom
----- Original Message ----
> From: CN <cn...@gr...>
> To: cpp...@li...
> Sent: Sun, October 31, 2010 7:40:32 AM
> Subject: [Cppcms-users] cppcms::widgets::file is always not set
>
> Basing on ./examples/forms/*, I use cppcms::widgets::file as follows:
>
> cppcms::widgets::text name;
> cppcms::widgets::file uploaded_file;
> cppcms::widgets::submit submit;
> name.non_empty();
> uploaded_file.non_empty();
>
> This is called as usual:
>
> c.info.load(context());
>
> My problem is that
>
> c.info.validate()
>
> always returns false. Widget "name" does have been fed with string, but
> "uploaded_file" is always not set:
>
> std:cout << c.info.uploaded_file.value()->filename() << std::endl;
>
> raises exception "File was not loaded".
>
> Calling method cppcms::widgets::file::load() does not feed anything to
> itself, either:
>
> c.info.uploaded_file.load(context());
>
> Helps are much welcome!
>
> Best Regards,
> CN
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
|