stream_resolve_include_path 返回错误?

stream_resolve_include_path returning false?

我有一个正在实施 InputFilterProviderInterface 的字段集。我的 getInputFilterSpecification 函数如下所示:

public function getInputFilterSpecification() {
    $validator = new \Zend\Validator\File\Extension([
        'jpg',
        'jpeg',
        'png',
        'gif',
    ]);
    return [
        [
            'name' => 'logo',
            'required' => false,
            'validators' => [
                $validator,
            ],
        ],
    ];
}

如您所料,我正在尝试通过扩展名验证文件上传。

我的问题是验证器给出了错误消息

File is not readable or does not exist

查看 Extension class 我发现了导致问题的函数:stream_resolve_include_path($file)。当我 var_dump $file 我得到以下输出:

C:\Windows\Temp\php6BE7.tmp

所以...为什么 stream_resolve_include_path 无法解析此路径?我该如何解决?

目前 运行 在 Windows 虚拟机上。这是问题的一部分吗?即上述功能仅适用于兼容的操作系统?

短期解决方案 - 扩展验证器并覆盖 isValid 函数。

找到行:

if (empty($file) || false === stream_resolve_include_path($file)) {

并将其替换为:

if (empty($file) || false === is_file($file)) {