# Is it possible to limit the size of uploaded images?

**URL:** <https://forum.builder.io/t/is-it-possible-to-limit-the-size-of-uploaded-images/7135>\
**Category:** CMS\
**Tags:** api\
**Created:** [January 13, 2025, 6:18am UTC](https://forum.builder.io/t/is-it-possible-to-limit-the-size-of-uploaded-images/7135 "2025-01-13T06:18:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [January 16, 2025, 12:38pm UTC](https://forum.builder.io/t/is-it-possible-to-limit-the-size-of-uploaded-images/7135/2 "2025-01-16T12:38:23Z")

</div>

Hello @nnn,

In [Builder.io](https://www.builder.io/), the input type `file` does allow you to restrict the formats of the uploaded files using the `allowedFileTypes` option. However, if you want to limit the size of the images uploaded, you’ll need to handle this validation logic yourself after the file has been selected.

Yes, you can achieve size validation using the `onChange` event in a couple of ways:

1. **Client-side Validation** :

2. **Example Code** :

3. **Server-side Validation** :

While the `allowedFileTypes` helps with constraining the file format, you do need to handle size constraints in your code either through JavaScript for immediate feedback or on the server-side when handling the uploaded file.

For more details about managing custom components and their inputs, see the [Input Types for Custom Components](https://www.builder.io/c/docs/custom-components-input-types) documentation.

> [@How do I limit the number of list items a user can add to a custom component?](https://forum.builder.io/t/how-do-i-limit-the-number-of-list-items-a-user-can-add-to-a-custom-component/251):
>
> Let’s say you made a [custom react component](https://www.builder.io/c/docs/custom-react-components) for use in Builder that has some properties that rely on user input. If one of them is a list item, you might want to limit the number of items in that list to prevent a user from adding way too many. An example might be images in a carousel, or number of tabs. How can we do that? Luckily you can pass a function to onChange and validate the length of the list there. Here is a sample of how you might want to do that: onChange: (options) =\> { if (opt…

I hope this helps!

Thanks,

---

_[View the full topic](https://forum.builder.io/t/is-it-possible-to-limit-the-size-of-uploaded-images/7135)._
