Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb. 09, 2010, 02:26:03 PM
52593 Posts in 11677 Topics by 7490 Members
Latest Member: jessie stribling
News: PRADO 3.1.6 is released!
 
The PRADO Community » Prado v3.x » Bug Reports » TActiveFileUpload and content length exceeds the limit.... « previous next »
Pages: [1] Print
Author Topic: TActiveFileUpload and content length exceeds the limit....  (Read 1329 times)
natsimhan
Senior Member
***

Karma: 6
Offline Offline

Posts: 273



View Profile WWW
« on: Jun. 01, 2009, 04:53:24 PM »

There is a big problem with TActiveFileUpload and TFileUpload when the user upload a big file.

When the file is greater than the max (defined in php.ini), the control displays always loading's state and not the Error.... if I look in the iframe I see my page and not an empty body ?

I found the explication in help on  php.net : http://fr3.php.net/manual/en/ini.core.php

Quote
post_max_size
[...]
If the size of post data is greater than post_max_size, the $_POST and $_FILES  superglobals  are empty

So, that's a problem for Prado.... Application doesn't know that a request is in progress, and user waits, and waits, and waits....

In the same page to the next line on php.net we can read:
Quote
This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set.

I don't know if this is too complicate to adapt this on Prado, but I think this is a good feature.. for users and developpers :-)
Logged

tof06
PRADO v3.x Developer
Platinum Member
*****

Karma: 83
Offline Offline

Posts: 1027



View Profile
« Reply #1 on: Jun. 02, 2009, 08:01:12 AM »

Natsimhan, please post an issue for Milestone 3.1.6.

Thanks
Logged
natsimhan
Senior Member
***

Karma: 6
Offline Offline

Posts: 273



View Profile WWW
« Reply #2 on: Jun. 02, 2009, 08:18:52 AM »

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

Code: (php)
<?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;
    }
  }
# [...]
}

?>


Code: (javascript)
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;
},
[...]
});
Logged

rojaro
Global Moderator
Platinum Member
****

Karma: 36
Offline Offline

Posts: 620


PRADO aint no voodoo ...


View Profile WWW
« Reply #3 on: Nov. 01, 2009, 09:33:26 PM »

Nice one. Merged in r2728.
Karma++

Greetings from Rostock / Germany
- rojaro -
Logged

A mathematician is a machine for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970)
natsimhan
Senior Member
***

Karma: 6
Offline Offline

Posts: 273



View Profile WWW
« Reply #4 on: Nov. 02, 2009, 07:40:43 AM »

Nice one. Merged in r2728.
Karma++

Greetings from Rostock / Germany
- rojaro -

Thanks !
Logged

Pages: [1] Print 
« previous next »
Jump to: