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" <thomas.bytteb...@gmail.com>
>> To: <fw-general@lists.zend.com>
>> 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" <thomas.bytteb...@gmail.com>
>>>> To: <fw-general@lists.zend.com>
>>>> 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.

Reply via email to