# What does Laminas\\InputFilter\\FileInput do exactly?

**URL:** <https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069>\
**Category:** Components & MVC\
**Tags:** laminas-inputfilter\
**Created:** [January 25, 2021, 5:02pm UTC](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069 "2021-01-25T17:02:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fadi\_Obaji](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/fadi_obaji/32/888_2.png) [@Fadi\_Obaji](https://discourse.laminas.dev/u/Fadi_Obaji)\
**Post date:** [January 25, 2021, 5:02pm UTC](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069/1 "2021-01-25T17:02:30Z")

</div>

I’ve been researching [Laminas documentation for their FIleInput class](https://docs.laminas.dev/laminas-inputfilter/file-input/) and i haven’t found a decent explanation of what those filters and validators actually do.

I’m building a community website and planning to let users upload files and i want to apply security checks on those uploaded files.

So can Laminas\InputFilter\FileInput actually do that? or what does it do exactly?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [January 26, 2021, 9:29am UTC](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069/2 "2021-01-26T09:29:11Z")

</div>

Hello and welcome to our forums! 😃

> [@Fadi\_Obaji](#):
>
> So can Laminas\InputFilter\FileInput actually do that?

The `FileInput` is a special input type for handling uploaded files. The behaviour of this input type is different because the given value is first validated and then filtered. For all other input types it is the opposite.  
This means that the uploaded files are checked before they are filtered, e.g. renamed, moved or changed.  
The input type `FileInput` adds automatically the [validator `Laminas\Validator\File\Upload`](https://docs.laminas.dev/laminas-validator/validators/file/upload/).

---

<div class="post-metadata">

**Author:** ![Fadi\_Obaji](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/fadi_obaji/32/888_2.png) [@Fadi\_Obaji](https://discourse.laminas.dev/u/Fadi_Obaji)\
**Post date:** [January 28, 2021, 10:03pm UTC](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069/3 "2021-01-28T22:03:01Z")

</div>

Thanks for your reply!

Can it check the uploaded files for potential-hacking? like remove any hidden scripts that might be in the image header? or check the uploaded file if it’s actually a file or if it contains scripts that might damage the server and let hackers gain access to the server?

I just want to know what `validating` and `filtering` means. (Can i use and rely on this for securing the file upload?)

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [January 28, 2021, 10:36pm UTC](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069/4 "2021-01-28T22:36:44Z")

</div>

> [@Fadi\_Obaji](#):
>
> Can it check the uploaded files for potential-hacking? like remove any hidden scripts that might be in the image header? or check the uploaded file if it’s actually a file or if it contains scripts that might damage the server and let hackers gain access to the server?

No there are no validators for this kind of problems. Do you know any good libraries on this topic? This would allow to implement a [custom validator](https://docs.laminas.dev/laminas-validator/writing-validators/).

> [@Fadi\_Obaji](#):
>
> I just want to know what `validating` and `filtering` means.

Validation is the check of data like user inputs in form of text or file and filtering will sanitize the data, so it may alter it by removing undesired characters.

More information also can be found in documentation:

> **[Introduction - laminas-validator - Laminas Docs](https://docs.laminas.dev/laminas-validator/intro/#what-is-a-validator)**
>
> Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria.

[https://docs.laminas.dev/laminas-filter/intro/#what-is-a-filter](https://docs.laminas.dev/laminas-filter/intro/#what-is-a-filter)

And in the PHP documentation:

[https://www.php.net/manual/intro.filter.php](https://www.php.net/manual/intro.filter.php)
