phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

[BUG]: MimeType:validate finfo error #16647

Closed niden closed 2 months ago

niden commented 2 months ago
$this->add(
            (new File('file',['required' => true]))
                ->setLabel('Attach sample op-ed(available format:pdf,text,word):')
                ->addValidators([
                    new PresenceOf([
                        'message' => 'please upload an op-ed file',
                    ]),
                    new MimeType([
                        "types" => [
                            'application/pdf',
                            'application/msword',
                            'application/rtf',
                            'application/epub+zip',
                            'text/plain',
                        ],
                        "message" => "Allowed file types are :types"
                    ]),
                   new Max([
                        "size"     => "2M",
                        "included" => true,
                        "message"  => ":field exceeds the max size (:size)",
                    ])
                ])
        );

Error: Fatal error: Uncaught ValueError: finfo_file(): Argument #1 ($finfo) cannot be empty in...

Report and fix by https://github.com/zikezhang

niden commented 2 months ago

Resolved in https://github.com/phalcon/cphalcon/pull/16646