works, but it's too much of a hassle for me to add this extra script
everywhere in my application. I've located the problem and it's an
easy fix:
Within Zend_File_Transfer_Adapter_Abstract , function getFilename(), I changed:
$result[$file] = $directory . $this->_files[$file]['name'];
to
$result[$file] = ($this->_files[$file]['name']) ? $directory .
$this->_files[$file]['name'] : null;
probably not the best way to do it, but it works. I hope there will be
a proper fix to this problem some day.
Regards,
Pieter
On Tue, Nov 18, 2008 at 11:01 PM, Thomas Weidner <thomas.weidner@gmx.at> wrote:
> There is only one file adapter because you have only one $_FILES input
> array.
> Having multiple file adapters would not work. This is mentioned, because the
> first would try to receive the files and the second would then throw an
> exception because there are no more files to receive.
>
> What you have in those two variables is the same adapter.
>
> And actually you are calling isUploaded on the adapter (which hold all
> uploaded files) and not the form element (where this new method does not
> exist for now).
>
> Greetings
> Thomas Weidner, I18N Team Leader, Zend Framework
> http://www.thomasweidner.com
>
> ----- Original Message ----- From: "Goran Juric" <goran.juric@nacional.hr>
> To: <fw-mvc@lists.zend.com>
> Sent: Tuesday, November 18, 2008 10:33 PM
> Subject: Re: [fw-mvc] Zend_Form_Element_File value when not uploading
>
>
>>
>>
>>
>> Pieter-12 wrote:
>>>
>>> When submitting a form with this element, without selecting/uploading
>>> a document-file will return 'documents' as its value. Is there a
>>> particular reason why this is happening? Is there a way to easily
>>> circumvent this from happening or should I use the isUploaded()
>>> function of the adapter for each file-element?
>>>
>>
>> I am using something like this:
>>
>> $adapter = $form->getElement('doc')->getTransferAdapter();
>>
>> if ($adapter->isUploaded('doc') {
>> ...
>> }
>>
>> if ($adapter->isUploaded('employee_cv_file') {
>> ...
>> }
>>
>> And it works, but some things still bother me.
>>
>> As far as I can see, both of the file form elements return the same
>> adapter
>> class. So doing something like this:
>>
>> Let's say that you have 2 file elements, and on your form you upload only
>> the 'doc', and not the other one, you will get this:
>>
>> $adapter1 = $form->doc->getTransferAdapter();
>> $adapter2 = $form->employee_cv_file->getTransferAdapter();
>>
>> echo $adapter1->isUploaded(); // returns true
>> echo $adapter2->isUploaded(); // returns true
>>
>> but
>>
>> echo $adapter1->isUploaded('doc'); // returns true
>> echo $adapter1->isUploaded('emplyee_cv_file'); // returns false (note that
>> we are still using $adapter1)
>>
>> I find it strange to fetch the adapter from one element, and use this
>> adapter for checking two or more elements and having to provide the name
>> of
>> the element to the isUploaded method.
>>
>> Maybe it has something to do with the fact that currently we have only one
>> transfer adapter, and that the file element can support upload of multiple
>> files, but I still can't wrap my hand around it although my code does what
>> I
>> want it to do, just not in the way I would like it do it :) (It would be
>> more natural for me to either fetch the transfer adapter from the form
>> itself and that to check the isUploaded() method providing the element
>> name,
>> or the fetch multiple adapters each from his element and to test if the
>> file
>> was uploaded without providing the name of the element since the adapter
>> is
>> fetched from the element itself).
>>
>> Sorry for the lengthy post, but I would really appreciate some code
>> samples
>> showing the "proper way" to handle file uploading.
>>
>> Regards,
>>
>> Goran Juric
>> http://gogs.info/
>> --
>> View this message in context:
>> http://www.nabble.com/Zend_Form_Element_File-value-when-not-uploading-tp20567916p20568684.html
>> Sent from the Zend MVC mailing list archive at Nabble.com.
>
>
没有评论:
发表评论