FileUpload does not emit uploaded signal on completion in mshta
Added by Ronald Peer about 13 years ago
When a file upload is in progress, the dataReceived
, changed
, and fileToLarge
signals are emitted as expected. In internet explorer 7, chrome, and firefor also the uploaded
signal is emitted. But when loading the same page in mshta.exe (basically a wrapper around IE engine) the uploaded
signal is not received...
Anyone any idea what prevents the signal from being sent?
This is the code that creates the widget:
std::string s_template = "<div class=\"form\">"
"<p>"
"<label>Select the file to upload: </label></p><br />"
"<p>${upload_widget} ${upload-button}</p><br />"
"<p>${pbar}</p>"
"</div>";
template_ = new WTemplate(s_template, center_);
fu_ = new WFileUpload();
fu_->setFileTextSize(40);
progress_bar_ = new WProgressBar();
template_->bindWidget("pbar", progress_bar_);
fu_->setProgressBar(progress_bar_);
fu_->changed().connect(this, &HelloApplication::FuChanged);
fu_->changed().connect(boost::bind(&HelloApplication::FuStatus, this, "File upload changed"));
fu_->uploaded().connect(boost::bind(&HelloApplication::FuUploaded, this, "File upload finished"));
fu_->dataReceived().connect(boost::bind(&HelloApplication::FuStatus, this, "Data received"));
fu_->fileTooLarge().connect(boost::bind(&HelloApplication::FuStatus, this, "File too large"));
template_->bindWidget("upload_widget", fu_);
button_upload = new WPushButton("Upload");
button_upload->setDisabled(true);
button_upload->clicked().connect(this, &HelloApplication::FuUpload);
template_->bindWidget("upload-button", button_upload);
Replies (5)
RE: FileUpload does not emit uploaded signal on completion in mshta - Added by Wim Dumon about 13 years ago
Ronald,
I can reproduce this, I'll take a look at it.
Wim.
RE: FileUpload does not emit uploaded signal on completion in mshta - Added by Ronald Peer about 13 years ago
Ok, thank you!
If there is anything we can do (like debugging certain Wt code) to pinpoint what the cause of this problem is please let us know.
Regards. Ronald
RE: FileUpload does not emit uploaded signal on completion in mshta - Added by Wim Dumon about 13 years ago
Hello Ronald,
I found the reason here: http://msdn.microsoft.com/en-us/library/ms536474%28v=vs.85%29.aspx
Wt's file upload uses an iframe.
Add these lines to WFileUpload.C
if (fileUploadTarget_) {
DomElement *i = DomElement::createNew(DomElement_IFRAME);
i->setProperty(PropertyClass, "Wt-resource");
i->setProperty(PropertySrc, fileUploadTarget_->url());
i->setName("if" + id());
+ if (app->environment().agentIsIE()) {
+ // http://msdn.microsoft.com/en-us/library/ms536474%28v=vs.85%29.aspx
+ // HTA's (started by mshta.exe) have a different security model than
+ // a normal web app, and therefore a HTA browser does not allow
+ // interaction from iframes to the parent window unless this
+ // attribute is set. If omitted, this causes the 'uploaded()'
+ // signal to be blocked when a Wt app is executed as a HTA.
+ i->setAttribute("APPLICATION", "yes");
+ }
DomElement *form = result;
form->setAttribute("method", "post");
form->setAttribute("action", fileUploadTarget_->url());
These changes will appear in the public git repository soon.
Best regards,
Wim.
RE: FileUpload does not emit uploaded signal on completion in mshta - Added by Ronald Peer about 13 years ago
Tried your solution, and it works!
I'm not sure, but should WWebWidget::updateDom() not also be extended with this code?
Seems that this may have potentially the same problem.
Thanks,
Ronald
RE: FileUpload does not emit uploaded signal on completion in mshta - Added by Wim Dumon about 13 years ago
Hello Ronald,
Our IE6 specialist told me in a funny way that it won't cause a problem there (mainly because there's no scripting in that iframe)
Best regards,
Wim.