Thread: [Cppcms-users] cppcms::widgets::file is always not set
Brought to you by:
artyom-beilis
From: CN <cn...@gr...> - 2010-10-31 09:25:20
|
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 |
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 > |
From: CN <cn...@gr...> - 2010-11-01 06:06:33
|
On Sun, 31 Oct 2010 18:19:49 +0800, Artyom <art...@ya...> wrote: > 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" I have added everything you suggested. Now I get "503 - Service Not Available". My cppCMS application appears to have failed to catch the posted form sent from browser. My problem perhaps fall in the realm of web server administration instead of cppCMS, but helps are greatly appreciated. This comes from Opera's source inspection: <html> <body> <h1>Upload your file</h1> <form method="post" action="http://localhost/upload" enctype="multipart/form-data" accept-charset="UTF-8"> <p>Name: <span class="cppcms_form_input"><input type="text" name="_1" ></span></p> <p><span class="cppcms_form_input"><input type="file" name="_2" ></span></p> <p><span class="cppcms_form_input"><input type="submit" name="_3" value="Upload" ></span></p> </form> </body> <html> No error is logged by my cppCMS application. The following two lighttpd log entries appear after the web page is opened by browser: 2010-11-01 13:35:30: (mod_fastcgi.c.2979) got proc: pid: 0 socket: unix:/tmp/cppcms-socket load: 1 2010-11-01 13:35:30: (mod_fastcgi.c.1508) released proc: pid: 0 socket: unix:/tmp/cppcms-socket load: 0 The following entries are added to lighttpd log after I submit the form in browser. 2010-11-01 13:35:38: (mod_fastcgi.c.2979) got proc: pid: 0 socket: unix:/tmp/cppcms-socket load: 1 2010-11-01 13:35:38: (mod_fastcgi.c.3041) write failed: Broken pipe 32 2010-11-01 13:35:38: (mod_fastcgi.c.1508) released proc: pid: 0 socket: unix:/tmp/cppcms-socket load: 0 Privileges look fine, too: # ls -l /tmp/cppcms-socket srwxrwxrwx 1 www-data www-data 0 2010-11-01 12:39 /tmp/cppcms-socket Regards, CN |