Bug #4772
[wt-3.3.5] WFileUpload does not emit signal uploaded if no file is selected
Start date:
02/26/2016
Due date:
% Done:
0%
Estimated time:
Description
hey,
WFileUpload does not emit signal uploaded if no file is selected a it does until wt-3.3.3. Moreover, once called WFileUpload::upload() whit no file selected you cannot use the file upload again even if you select a file.
Wt::WApplication* MyApp(const Wt::WEnvironment& env) { auto App(new WApplication(env)); auto w = App->root(); Wt::WFileUpload *upload = new Wt::WFileUpload(w); // Provide a button Wt::WPushButton *uploadButton = new Wt::WPushButton("Send", w); WText *FileName = new WText(w); // Upload when the button is clicked. uploadButton->clicked().connect(std::bind([=](){ upload->upload(); // uploadButton->disable(); })); // Upload automatically when the user entered a file. // React to a successful upload. upload->uploaded().connect(std::bind([=](){ cout << "uploaded emited" << endl; if (upload->empty()) { uploadButton->enable(); } else { FileName->setText(upload->clientFileName()); } })); return App; }
Updated by Стойчо Стефанов Stoycho Stefanov almost 7 years ago
I just found a work around. The upload button has to remain disabled until a file is selected
Wt::WPushButton *uploadButton = new Wt::WPushButton("Send", w); uploadButton->disable(); // remains disabled until a file is selected upload->changed().connect(std::bind([=](){ uploadButton->enable(); // enable if file is selected })); uploadButton->clicked().connect(std::bind([=](){ upload->upload(); uploadButton->disable(); })); upload->uploaded().connect(std::bind([=](){ cout << "uploaded emited" << endl; if (not upload->empty()) { FileName->setText(upload->clientFileName()); } uploadButton->enable(); }));
However, I have to fix old code due to this behaviour change :(
Updated by Koen Deforche almost 7 years ago
- Status changed from New to Resolved
We've restored the 3.3.4 behaviour.
Updated by Koen Deforche over 6 years ago
- Status changed from Resolved to Closed
- Target version set to 3.3.6