Issue Type: Bug Created: 2009-03-11T04:25:34.000+0000 Last Updated: 2009-03-12T15:42:25.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)
Reporter: Johan B.W. de Vries (jbwdevries) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer
Related issues: Attachments:
I added two times a Zend_Form_Element_File, one with the name 'file', the other with the name 'file_two'. When asking the Zend_Transfer_Adapter for getFileName('file'), I get an array with both elements (fair enough; though I still find this weird). However, when asking for getFileName(), it returns the following:
<pre class="highlight">var_export($adapter->getFileName()); array ( 'file_two' => 'D:\\tmp\\php\\uploads\\size-256.txt', 'file' => 'Array\\size-1024.txt', )
("D:\tmp\php\uploads\" being my upload_tmp_dir).
Problem is, of course, the second element, which has 'Array' instead of the directory. This is because when asking for getDestination($file) (which getFileName does), it returns an array with both elements:
<pre class="highlight">var_export($adapter->getDestination['file']); array ( 'file_two' => 'D:\\tmp\\php\\uploads', 'file' => 'D:\\tmp\\php\\uploads', )
I've tested with 1.7.6 as well as the SVN version from http://framework.zend.com/svn/framework/… (revision 142740).
You can, of course, make the name yourself with getFileInfo(), concatenating the destination, a DIRECTORY_SEPARATOR and the name. However, from what I see, that file doesn't exist either.
Posted by Thomas Weidner (thomas) on 2009-03-11T08:15:16.000+0000
The reason is that "_" is used as seperator for SubForms... Therefor it looks internally which other file elements are also within the "file" SubForm "file_1", "file_2" and so on... and returns them all.
Simply use another seperator because "_" is also used overall the complete framework as directory seperator, and within several other places.
Posted by Johan B.W. de Vries (jbwdevries) on 2009-03-11T08:32:02.000+0000
Isn't the underscore like the most used separator for form element names? Mostly because those names match columns in a database somewhere? Maybe it's an option to make the separator configurable?
And regardless of what's behind it, shouldn't getFileName() return proper results, even if it means returning files from subforms? From what I gather, the Zend_File_Transfer_Adapter_Abstract deals with all uploaded files anyhow.
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-03-11T08:49:23.000+0000
I agree with Johan, this should be resolved, one way or another.
Posted by Thomas Weidner (thomas) on 2009-03-11T08:56:33.000+0000
Please dont discuss here useless things. :-) If I would not have seen this as issue I would already have closed it. I just wanted to give a quick solution as we can only fix this for the next release which is earliest in 6 weeks.
Posted by Thomas Weidner (thomas) on 2009-03-11T11:46:11.000+0000render(new Zend\_View());?>
Posted by Johan B.W. de Vries (jbwdevries) on 2009-03-12T00:54:02.000+0000
I've tinkered around with your example, couldn't (at first) find the problem. However; if you change the order of the elements:
<pre class="highlight"> $form->addElement($element); $form->addElement($element2);
<pre class="highlight"> $form->addElement($element2); $form->addElement($element);
The bug surfaces, using either Zend 1.7.6 or revision 14274.
Posted by Johan B.W. de Vries (jbwdevries) on 2009-03-12T00:56:55.000+0000
Purely cosmetics; used the ``` tag to display the results better.
Posted by Johan B.W. de Vries (jbwdevries) on 2009-03-12T00:58:53.000+0000
"Purely cosmetics;" -> I meant I update the issue summary, it looked weird without the code tags.
Posted by Thomas Weidner (thomas) on 2009-03-12T15:42:20.000+0000
Fixed with r14287.
Have you found an issue?
See the Overview section for more details.