Closed BigMichi1 closed 3 years ago
@BigMichi1 As written before:
as the
RenameUpload
filter is applied before calling the validator
The file validators are run before the filters. Please compare with:
Please add a full code example which allows to reproduce the problem or create a pull request with a unit test which illustrates the problem.
@BigMichi1 Please set the type for the input:
$config = [
[
'type' => Laminas\InputFilter\FileInput::class,
'name' => 'logo',
'required' => false,
// …
See the related documentation: https://docs.laminas.dev/laminas-inputfilter/file-input/#basic-usage
thank you so much, exactly this line was missing. it looks like I should not have started to use that array notation, I was also playing around with the examples from https://docs.laminas.dev/laminas-inputfilter/file-input/#basic-usage and they worked. just overlooked this one little piece of information
Bug Report
Summary
when the
RenameUpload
filter is added to a field containing theUploadFile
validator theUploadFile
validator fails and issues an error about a possible attacksee also https://github.com/laminas/laminas-filter/issues/33
the reason for that is that inside the
UploadFile
a check is performed using thetmp_name
to check if the file was uploaded by using the methodis_uploaded_file
. as theRenameUpload
filter is applied before calling the validator thetmp_name
has been already changed based on the configuration for theRenameUpload
filter and so the check fails astmp_name
is no longer the name to the uploaded file in the$_FILES
arrayCurrent behavior
impossible to upload a file when the
RenameUpload
filter and theUploadFile
validator are used on the same fieldHow to reproduce
configure a field like this (using array notation for configuring a field):
Expected behavior
the filter and validator can be used together