\Zend\Filter\File\Rename not working for multiple files / bug

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

\Zend\Filter\File\Rename not working for multiple files / bug

cbichis
Hi,

I have a form with a html5 multiple file upload element.

         $this->add(array(
             'type' => 'File',
             'name' => 'images',
             'options' => array(
                 'label' => 'images',
                 'label_options' => array('always_wrap' => true),
             ),
             'attributes' => array(
                 'id' => 'images',
                 'multiple' => true,
             ),
         ));
         $this->filter->add(array(
             'name' => 'images',
             'required' => false,
             'filters' => array(
                 array(
                     'name' => '\Zend\Filter\File\Rename',
                     'options' => array(
                         'target' => './data/tmpuploads/images.jpg',
                         'randomize' => true,
                     )
                 ),
             ),
         ));

I noticed the \Zend\Filter\File\Rename doesnt seems to work for multiple
files as it doesnt know how to process a 2 levels array. I guess this is
a bug. There is no file filter which knows to work for multiple files ?


     public function filter($value)
     {
         if (!is_scalar($value) && !is_array($value)) {
             return $value;
         }

         // An uploaded file? Retrieve the 'tmp_name'
         $isFileUpload = false;
         if (is_array($value)) {
*if (!isset($value['tmp_name'])) {*
                 return $value;
             }

             $isFileUpload = true;
             $uploadData = $value;
             $value      = $value['tmp_name'];
         }

Of course I can define my own filter class or use manually the filter
within a for loop.

Cristian Bichis