I have a fieldset that is implementing InputFilterProviderInterface
. My getInputFilterSpecification
function looks like this:
public function getInputFilterSpecification() {
$validator = new \Zend\Validator\File\Extension([
'jpg',
'jpeg',
'png',
'gif',
]);
return [
[
'name' => 'logo',
'required' => false,
'validators' => [
$validator,
],
],
];
}
As you can guess, I am trying to validate the file upload by extension.
My problem is that the validator is giving the error message
File is not readable or does not exist
Looking into the Extension
class I found the function that's causing the issue: stream_resolve_include_path($file)
. When I var_dump
$file
I get the following output:
C:\Windows\Temp\php6BE7.tmp
So... Why is stream_resolve_include_path
failing to resolve this path? How do I fix it?
This is currently running on a Windows Virtual Machine. Is this part of the problem? i.e. the above function only works on compatible operating systems?
Short term solution - extend the validator and overwrite the isValid
function.
Find the line:
if (empty($file) || false === stream_resolve_include_path($file)) {
and replace it with:
if (empty($file) || false === is_file($file)) {