如果与多个文件一起使用,inputfilter会引发错误

时间:2018-11-05 09:20:18

标签: zend-framework zend-form zend-framework3 zend-inputfilter

我使用Inputfilter,该格式适用于我上传1个文件的表单。如果我使用形式备份上传多个文件,则会收到警告消息。

首先是警告:

  

警告:finfo_file():提供的资源不是有效的file_info   资源中   C:\ wamp64 \ www \ xyz \ vendor \ zendframework \ zend-validator \ src \ File \ MimeType.php

该信息下方的格式是:“文件类型不匹配”,因此我认为使用了Inputfilter

以下是我的Inputfilter的摘要:

    $inputFilter->add([
            'type'     => 'Zend\InputFilter\FileInput',
            'name'     => 'Document_Path',  
            'required' => true,    
            'filters'  => [        
                    [
                            'name' => \Zend\Filter\File\RenameUpload::class,
                            'options' => [
                                    'use_upload_name'=>true,
                                    'use_upload_extension' => true,
                                    'randomize' => false,
                                    'overwrite' => true,
                                    'target' => './public/files/pads',
                            ],
                    ],
            ],
            'validators' => [      // Validators.
                    [
                            'name' => \Zend\Validator\File\Extension::class,
                            'options' => [
                                    'extension' => 'pdf',
                                    'message' => 'File extension not match',
                            ],
                    ],
                    [
                            'name' => \Zend\Validator\File\MimeType::class,
                            'options' => [
                                    'mimeType' => 'application/pdf',    //'text/xls', 'text/xlsx',
                                    'message' => 'File type not match',
                            ],
                    ],
                    [
                            'name' => \Zend\Validator\File\Size::class,
                            'options' => [
                                    'min' => '1kB',  // minimum of 1kB
                                    'max' => '8MB',
                                    'message' => 'File too large',
                            ],
                    ],
            ]
    ]);

在这里输入过滤器可以使用的表单元素:

        $this->add([
            'name' => 'Document_Path',
            'type' => 'File',
            'options' => [
                    'label' => 'path to file',
            ],
    ]);

这里是用于多个文件上传的文件:

        $this->add([
            'name' => 'Document_Path',
            'type' => 'File',
            'options' => [
                    'label' => 'pick folder of files',
            ],
             'attributes' => [ 
                  'multiple' => true,
              ],
    ]);

我使用相同的文件进行测试,这些文件适用于普通(1个文件)上传。当然是pdf文件。

感谢任何帮助,建议和解决方法。

0 个答案:

没有答案