Comments (2)
Once the file is moved, any kind of upload validation will obviously fail.
In practice, the "is uploaded file" validation can only be performed when validating unfiltered input.
from laminas-validator.
@diegobittencourt
Unfortunately, I cannot reproduce the problem.
This is my short test:
include_once __DIR__ . '/vendor/autoload.php';
if (count($_FILES)) {
$config = [
[
'type' => Laminas\InputFilter\FileInput::class,
'name' => 'image',
'validators' => [
[
'name' => Laminas\Validator\File\UploadFile::class,
],
[
'name' => Laminas\Validator\File\MimeType::class,
'options' => [
'mimeType' => [
'image/jpeg',
'image/png',
],
],
],
[
'name' => Laminas\Validator\File\IsImage::class,
],
[
'name' => Laminas\Validator\File\ImageSize::class,
'options' => [
'minWidth' => 128,
'minHeight' => 128,
'maxWidth' => 4096,
'maxHeight' => 4096,
],
],
],
'filters' => [
[
'name' => Laminas\Filter\File\RenameUpload::class,
'options' => [
'target' => './docs',
'use_upload_name' => false,
'use_upload_extension' => true,
'overwrite' => true,
'randomize' => true,
],
],
],
],
];
$inputFilter = (new Laminas\InputFilter\Factory())
->createInputFilter($config)
->setData($_FILES);
var_dump($_FILES);
var_dump($inputFilter->isValid());
var_dump($inputFilter->getMessages());
// Execute rename filter
$inputFilter->getValues();
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit">
</form>
Once the file is moved, any kind of upload validation will obviously fail.
The input Laminas\InputFilter\FileInput::class
of laminas-inputfilter runs the validators before the filters (the opposite behaviour of Laminas\InputFilter\Input::class
). So everything works as expected.
from laminas-validator.
Related Issues (20)
- Switch from Travis-Ci to GitHub actions for continuous integration workflow HOT 1
- IsCountable validator is not registered in ValidatorPluginManager HOT 4
- NotEmpty to allow null but dont allow no value HOT 4
- Package container-interop/container-interop is abandoned HOT 1
- run
- Missing Ukraine(UA) in Iban validator HOT 2
- Removal of `container-interop/container-interop`
- Drop Zend related aliases and anything providing compatibility with Zend HOT 3
- Drop Service Manager v2 Compatibility
- Drop or upgrade Laminas\Math HOT 1
- GpsPoint validator needs a rewrite because it returns true for the input "foo, bar" HOT 5
- `@psalm-assert` error upstream due to `ValidatorChain` HOT 1
- Dependency Dashboard
- Digits validator not working because laminas-filter dependency is not listed in `require` section of composer.json HOT 1
- Upload validator should be able to handle array of arrays returned by ServerRequestInterface::getUploadedFiles HOT 1
- Enum-Validator HOT 4
- Improvement to laminas-validator documentation HOT 3
- Undocumented $context feature of validator's isValid($value, array $context = null) method
- File extension comparison treats some distinct extensions as equal HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laminas-validator.