I found a solution wich works for me under Prado 3.1.5 and 3.1.4
The idea is in Client side to add vars in the url in form's action just before the submit's form and restore the old url after the call.
And in Server side, add a condition in onPreRender of TActiveUpload if no postback but vars in $_GET as this is not a "normal". TActiveFileUpload understands that this is the "bug" and all POST informations are deleted. It just need to get the vars from GET for construct a right response wich can be read by client.
If the file uploaded is too big, an error UPLOAD_ERR_FORM_SIZE is read by client and it is display to user.
Below the code of changes, I think this can be include in next version of Prado without lot of modifications. If you don't want waiting for next release, this can be added "a mano".
I'll be post a issue for milestone 3.1.6
<?php
class TActiveFileUpload
{
# [...]
public function onPreRender($param) {
parent::onPreRender($param);
$this->getPage()->getClientScript()->registerPradoScript('effects');
$this->getPage()->getClientScript()->registerPradoScript('activefileupload');
if(!$this->getPage()->getIsPostBack()
&& isset($_GET['MTActiveFileUpload_Input_ID'])
&& isset($_GET['MTActiveFileUpload_Target_ID'])
&& $_GET['MTActiveFileUpload_Input_ID'] == $this->getClientID() ) {
$this->_errorCode = UPLOAD_ERR_FORM_SIZE;
echo <<<EOS
<script language="Javascript">
Options = new Object();
Options.clientID = '{$this->getClientID()}';
Options.targetID = '{$_GET['MTActiveFileUpload_Target_ID']}';
Options.localName = '$localName';
Options.fileName = '{$filename}';
Options.fileSize = '{$this->getFileSize()}';
Options.fileType = '{$this->getFileType()}';
Options.errorCode = '{$this->getErrorCode()}';
parent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options);
</script>
EOS;
exit;
}
}
# [...]
}
?>
Prado.WebUI.TActiveFileUpload = Base.extend(
{
[...]
fileChanged : function(){
// show the upload indicator, and hide the complete and error indicators (if they areSn't already).
this.flag.value = '1';
this.complete.style.display = 'none';
this.error.style.display = 'none';
this.indicator.style.display = '';
// set the form to submit in the iframe, submit it, and then reset it.
this.oldtargetID = this.form.target;
this.form.target = this.options.targetID;
this.oldformAction = this.form.action;
/*NEW*/ this.form.action += '?MTActiveFileUpload_Input_ID='+this.options.inputID+'&MTActiveFileUpload_Target_ID='+this.options.targetID;
this.form.submit();
this.form.target = this.oldtargetID;
/*NEW*/ this.form.action = this.oldformAction;
},
[...]
});