Project

General

Profile

Actions

Bug #4772

closed

[wt-3.3.5] WFileUpload does not emit signal uploaded if no file is selected

Added by Стойчо Стефанов Stoycho Stefanov about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
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;
}
Actions #1

Updated by Стойчо Стефанов Stoycho Stefanov about 8 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 :(

Actions #2

Updated by Koen Deforche about 8 years ago

  • Status changed from New to Resolved

We've restored the 3.3.4 behaviour.

Actions #3

Updated by Koen Deforche almost 8 years ago

  • Status changed from Resolved to Closed
  • Target version set to 3.3.6
Actions

Also available in: Atom PDF