Issues

ZF-5126: Multi files upload handling

Issue Type: Improvement Created: 2008-12-01T11:47:47.000+0000 Last Updated: 2012-11-20T20:53:27.000+0000 Status: Closed Fix version(s): Reporter: bandar (bandirsen) Assignee: None Tags: - Zend_File_Transfer

Related issues: - ZF-5652

Attachments:

Description

I just wanna ask about multi files upload validation/filter handling by Zend_File_Transfer_Adapter Is it possible to add same validators or filters for different files in same upload session ?

I try following code but not working ( assumes I have a form post data with 2 input file named 'file1" and "file2" )

<pre class="highlight">
public function indexAction()
{
     $request = $this->getRequest();
     if ($request->isPost()) {
        $upload = new Zend_File_Transfer_Adapter_Http();
        $upload->addValidator('Extension', true, array('pdf'), 'file2');
        $upload->addValidator('Extension', true, array('doc'), 'file1');
        var_dump($upload->isValid());
        exit;
      }
}
  • expected result : will return true if I upload .pdf type file for 'file1' and .doc type file for 'file2'
  • result : it will never accept '.pdf' type file (its only accept .doc type file) (please correct me if my code is for wrong purpose)

doing some little research, I found even we separate the validator for each files, the validator name is refering to same adapter validator stacks, so if we are using same validator for different file ( in our case 'Extension' ) if will refer to last 'Extension' validator in the stack and ignoring previous added 'Extension' validator, in other word we must add and remove 'same validator' to validating multi files upload with different validating policy.

is it possible to add 'custom validator name' features to validators/filters so when we need 2 or more same validator/filter with different policy (in our case 2 'Extension' validator, one for pdf files, and one for doc file) we can avoid validator/filter name conflict.

btw If there already feature like this, would you please tell me how to use it? or maybe it should be like this by design

Regards, Bandirsen

and sorry for my english :)

Comments

Posted by Thomas Weidner (thomas) on 2009-01-03T13:58:55.000+0000

Manual clearly states that multiple validators of the same type are not allowed and will overwrite each other.

Posted by bandar (bandirsen) on 2009-01-09T22:01:29.000+0000

Hi Thomas,

Thanks for reply so it's by design.
then in my use case, we must repeating add 'Extension Validator' and call isValid() method manually for each file when validating upload multiple files with with different extension type.

Is there any plan to change behavior this in future ?

Posted by bandar (bandirsen) on 2009-05-18T18:58:51.000+0000

Hi Thomas,

Sorry if I late for this. I see this issue is still open, and I think we should change this issue status to closed / resolved. I was trying to change its status but I can find how to do it.

Regards, Bandirsen

Posted by St├ęphane (stephane) on 2009-09-16T04:10:49.000+0000

Hello Thomas,

Any news about this improvement?

By the way, I hope messages will be refactored to include the name of the input as key of the messages (like for standard validators). For example, we could have something like this:

<pre class="highlight">
array(2) {
  ["MEDIA"] => array(1) {
    ["fileSizeTooBig"] => string(76) "Maximum allowed size for file 'yahoo.jpg' is '20kB' but '154.77kB' detected"
  }
  ["THUMBNAIL"] => array(1) {
    ["fileSizeTooBig"] => string(77) "Maximum allowed size for file 'google.jpg' is '5kB' but '181.47kB' detected"
  }
}

Posted by Thomas Weidner (thomas) on 2009-09-16T11:35:01.000+0000

Standard validators to not add the element name to the message. It depends on the validator how the message will look like.

Some prework within Zend_Validate has already been done. But it still needs some time. Several other issues have more votes than this one. And I am vote-driven ;-)

So as summary: Not forgotten... please be patient. :-)

Posted by Rob Allen (rob) on 2012-11-20T20:53:27.000+0000

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts