1
|
#include <Wt/WApplication>
|
2
|
#include <Wt/WEnvironment>
|
3
|
#include <Wt/WBreak>
|
4
|
#include <Wt/WContainerWidget>
|
5
|
#include <Wt/WPushButton>
|
6
|
#include <Wt/WText>
|
7
|
#include <Wt/WFileUpload>
|
8
|
#include <Wt/WMessageBox>
|
9
|
|
10
|
using namespace Wt;
|
11
|
using namespace std;
|
12
|
|
13
|
////////////////////////////////////////////////////////////////////
|
14
|
class TriggerWFileUploadBugWidget: public Wt::WContainerWidget {
|
15
|
public:
|
16
|
TriggerWFileUploadBugWidget(Wt::WContainerWidget *parent = 0);
|
17
|
|
18
|
virtual ~TriggerWFileUploadBugWidget() {
|
19
|
}
|
20
|
|
21
|
private:
|
22
|
Wt::WFileUpload *firstfileUpload;
|
23
|
|
24
|
WPushButton *loadButton;
|
25
|
|
26
|
void doUpload();
|
27
|
void fileUploaded();
|
28
|
void fileMuchTooLarge(::int64_t size);
|
29
|
};
|
30
|
|
31
|
|
32
|
TriggerWFileUploadBugWidget::TriggerWFileUploadBugWidget(WContainerWidget *parent)
|
33
|
:
|
34
|
WContainerWidget(parent)
|
35
|
{
|
36
|
this->addWidget(new WText("First: "));
|
37
|
firstfileUpload = new Wt::WFileUpload(this);
|
38
|
firstfileUpload->setFileTextSize(40);
|
39
|
|
40
|
firstfileUpload->uploaded().connect(this, &TriggerWFileUploadBugWidget::fileUploaded);
|
41
|
firstfileUpload->fileTooLarge().connect(this, &TriggerWFileUploadBugWidget::fileMuchTooLarge);
|
42
|
|
43
|
this->addWidget(new WBreak());
|
44
|
loadButton = new WPushButton("Load", this);
|
45
|
|
46
|
loadButton->clicked().connect(this, &TriggerWFileUploadBugWidget::doUpload);
|
47
|
}
|
48
|
|
49
|
////////////////////////////////////////////////////////////////
|
50
|
void TriggerWFileUploadBugWidget::doUpload() {
|
51
|
firstfileUpload->upload();
|
52
|
|
53
|
cerr << "Started upload" << endl;
|
54
|
loadButton->disable();
|
55
|
}
|
56
|
|
57
|
void TriggerWFileUploadBugWidget::fileUploaded() {
|
58
|
string firstfileClient=firstfileUpload->clientFileName().narrow();
|
59
|
cerr << "Entered allFilesUploaded" << endl;
|
60
|
|
61
|
WMessageBox::show("File successfully uploaded","Got file: " + firstfileClient,Ok);
|
62
|
}
|
63
|
|
64
|
void TriggerWFileUploadBugWidget::fileMuchTooLarge(::int64_t size) {
|
65
|
|
66
|
// NEVER CALLED !!!
|
67
|
|
68
|
WMessageBox::show("Error","File too large",Ok);
|
69
|
}
|
70
|
|
71
|
WApplication *createApplication(const WEnvironment& env) {
|
72
|
Wt::WApplication *app = new Wt::WApplication(env);
|
73
|
|
74
|
app->setTitle("WFileUpload bug");
|
75
|
|
76
|
new TriggerWFileUploadBugWidget(app->root());
|
77
|
|
78
|
return app;
|
79
|
}
|
80
|
|
81
|
int main(int argc, char **argv)
|
82
|
{
|
83
|
return WRun(argc, argv, &createApplication);
|
84
|
}
|
85
|
|