You checked for isValid... but it's not valid and I can't see what you are doing with the returned error message.

On the other hand I don't know what your browser does when the file exceeds the defined file size in the form. He could stop transmission, he could prevent to load the file, he could display a error message himself, and so on. It could also be that the browser still sends the file but the web server does not accept it.

As you setRequired to true, you should get a failure in any of the above cases when the validation fails.
So I expect that you have a general problem displaying error messages.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "Thomas Byttebier" <[email protected]>
To: "Thomas Weidner" <[email protected]>
Sent: Tuesday, February 17, 2009 3:12 PM
Subject: Re: [fw-general] User uploads file bigger than what's allowed in php.ini, can it be caught?


Thanks Thomas,
It seems to work now. I get no more exception when uploading files larger
than the allowed upload-size in php.ini. However it doesn't show a user
message telling the user what's going on either.

Thomas

2009/2/17 Thomas Weidner <[email protected]>

Please use r14096 or higher.

I'm sorry...
We had code freeze and a few changes for a new feature were not moved but
now they are integrated and things work like before.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "bytte" <[email protected]>
To: <[email protected]>
Sent: Tuesday, February 17, 2009 2:09 PM
Subject: Re: [fw-general] User uploads file bigger than what's allowed in
php.ini, can it be caught?



Thanks Thomas. I've used the code from the trunk and now it says:
Fatal error: Cannot access protected property
Zend_File_Transfer_Adapter_Http::$_callbackApc in
/Users/bytte/Sites/my-site/library/Zend/Form/Decorator/File.php on line
114





thomasW wrote:


Who knows ? ;-)
Try so use trunk and see if the problem is still there.

Several automatic additions have been applied there (automatic
setMaxFileSize, exception on missing decorator, automatic encoding).
If your problem is still not solved with trunk add a issue with
reproducable
code.
See the standalone example from my blog and try to reproduce the
behaviour
with how you did your code.

I'm sorry but the small piece of code is not enough for me to see where
the
problem could be.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "bytte" <[email protected]>
To: <[email protected]>
Sent: Monday, February 16, 2009 12:28 PM
Subject: Re: [fw-general] User uploads file bigger than what's allowed in
php.ini, can it be caught?



Bug in my code or bug in Zend Framework?



bytte wrote:


I'm now using setMaxFileSize().

Here's the (reduced for readability) code in my controller to retrieve
and
validate the form input. I have two forms on the same page so that's
why
I
do the array_key_exists thing to check which form was submitted. Might
not
be the best way of doing things.

file1 is the name of the upload file field.

if($this->_request->isPost()) {
$formData = $this->_request->getPost();
if(array_key_exists('file1',$formData)) {
if($bestandenForm->isValid($formData)) {
if ($_FILES['file1']['tmp_name']) {
$formData['file1'] = $_FILES['file1'];
}
//do something with the file via upload class
       //then redirect user if successful
}
} else {
//other form is submitted, validate and do something with it
}
}



thomasW wrote:


Use setMaxFileSize() instead of adding the field manually.

Beside that it seems like you are doing something wrong when
processing
the
files.
How does your validation/retrievment code looks like ?
This failure is thrown when you are trying to receive a non existant
file
for example.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "bytte" <
[email protected]>
To: <[email protected]>
Sent: Tuesday, February 10, 2009 10:51 PM
Subject: Re: [fw-general] User uploads file bigger than what's allowed
in
php.ini, can it be caught?



Thanks for the reply Thomas.

I added this line to the form (via Zend_Form of course, but this is
the
html
output):
<input id="MAX_FILES_SIZE" type="hidden" value="6291456"
name="MAX_FILES_SIZE"/>

I'm using Zend Framework 1.7.4 (downloaded about a week ago). I have
no
experience with Subversion so I'm not sure how to download the svn
trunk.




thomasW wrote:


Which release are you using ?
Can you try svn trunk ?

How did you add the MAX_FILES_SIZE ?
Where did you add it ?

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "bytte" <
[email protected]>
To: <[email protected]>
Sent: Tuesday, February 10, 2009 4:43 PM
Subject: [fw-general] User uploads file bigger than what's allowed
in
php.ini, can it be caught?



I'm using Zend_File via Zend_Form_Element_File to let my web
application's
users upload files. I use the following Validators:
$file1->setRequired(true)
      ->addValidator('NotEmpty',true)
  ->addValidator('Count',false,array('min' => 1, 'max' => 1))
  ->addValidator('MimeType', true, array('application/pdf'))
  ->addValidator('Extension',false,array('pdf'))
  ->addValidator('Size',false,array('max' => '6MB'));

It works ok and the validators seem to do their job well but on one
occasion: when the user tries to upload a file that's bigger than
what's
allowed in the server's php.ini file. That value is set to 10MB and
when
I
upload a file of let's say 12MB I just get this error:

Fatal error: Uncaught exception 'Zend_File_Transfer_Exception' with
message
'"file1" not found by file transfer adapter'.

If the user tries to upload a file that's bigger than 6MB (as
defined
in
the
Size validator) but smaller than 10MB it's ok as a user-friendly
message
is
shown to the user.

Is there a way to display a user-friendly message to the user when
he/she
tries to upload a file bigger than what's allowed in php.ini? Now
it
just
looks as if the application is broken.

For the record: I have set html's MAX_FILES_SIZE to 6MB as well.
--
View this message in context:

http://www.nabble.com/User-uploads-file-bigger-than-what%27s-allowed-in-php.ini%2C-can-it-be-caught--tp21936346p21936346.html
Sent from the Zend Framework mailing list archive at Nabble.com.





--
View this message in context:

http://www.nabble.com/User-uploads-file-bigger-than-what%27s-allowed-in-php.ini%2C-can-it-be-caught--tp21936346p21943430.html
Sent from the Zend Framework mailing list archive at Nabble.com.







--
View this message in context:

http://www.nabble.com/User-uploads-file-bigger-than-what%27s-allowed-in-php.ini%2C-can-it-be-caught--tp21936346p22035588.html
Sent from the Zend Framework mailing list archive at Nabble.com.





--
View this message in context:
http://www.nabble.com/User-uploads-file-bigger-than-what%27s-allowed-in-php.ini%2C-can-it-be-caught--tp21936346p22056988.html
Sent from the Zend Framework mailing list archive at Nabble.com.





--
Thomas Byttebier
Visserij 142
9000 Gent
Belgium

http://www.thehotseat.be


Reply via email to