2009年3月28日星期六

Re: [fw-mvc] form->getValues and file upload

Yes, you misunderstood completly.

When you want to "GET" the content of a file element you will of course get
the file itself which means that it's being uploaded.

When you want to validate a element you should call isValid() and not
getValues().
When you have to change the content you should apply file-filters... they
were build just for this usecase.
Only when the files are VALID you should call receive() or getValues().

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

----- Original Message -----
From: "Simone Cosci" <s.cosci@nextidea.it>
To: <fw-mvc@lists.zend.com>
Sent: Saturday, March 28, 2009 7:47 PM
Subject: Re: [fw-mvc] form->getValues and file upload


>
>> Simone,
>>
>> In case the file was already received, the received method returns true
>> and
>> not null.
>> Only when the upload is not possible due to failed validation it returns
>> false, and null by getValues().
>>
>> The reason is, that when the file is not uploaded (because it's not
>> valid)
>> it will of course also not have a value due to being empty.
>
> Thank you for your answer but for me the problem is the concept
> he's talking about the $form->getValues() method ...
> The getValue() method of a Form_Element_File causes the
> receive() method that call the adapter's receive() method to really move
> the
> file from tmp dir as follow:
>
> $adapter = $this->getTransferAdapter();
> if ($adapter->receive($this->getName())) {
> =>
> if (!move_uploaded_file($content['tmp_name'], ($directory .
> $content['name']))) {
>
> IMHO this approach is too much restrictive 'cause the file is received (so
> moved
> an renamed to original name) during the validation process of a Form or
> everytime the $form->getValues() method is called (also for other data)
> For my case it's necessary to validate the file when it's still in tmp dir
> ...
> then if all it's ok (size, mime, dim etc) I'll provide to scale it, to
> make a
> thumb copy renaming them from the tmp_name to $id . ".jpg", watermarking
> etc ...
>
> ... or maybe I missunderstood
>
>>
>> For the next minor release, the change you mentioned is no longer
>> necessary
>> as you can get file informations since several weeks also after the file
>> has
>> already been received.
>>
>
> good news
>
> bye
> Simone
>
>
>
> --
> ________________________________________________________________________________
>
> Simone Cosci - Planet S.r.l. Sistemi informatici
> Via Giorgio Ambrosoli, 39 - 50018, Scandicci, Firenze, Italy
> WEB: http://www.planetweb.it - http://www.ticka.it
> E-Mail s.cosci@nextidea.it
> Tel. +39 055 7350271 - Fax. +39 055 7351109
> ________________________________________________________________________________
>

没有评论: