How to validate image dimension (height x width) before upload?

I need to validate image dimension to only allow image that meets required dimension to be used for upload. I’m not aware of such validation available in Wappler but I googled and found tut on how to achieve it using php and javascript. I think it’d be too complicated for me to integrate that script with Wappler’s validation.

Is there any idea how can I achieve it using Wappler’s build in functions without having to resort external resources?

Hello,
You can do this in your server action and using a condition if the loaded image width > XXXpx && height > YYYpx.
If the condition is met - do the insert and any other actions required, otherwise return an error message/status.

1 Like

That means I have to execute upload first and delete the file if it doesn’t meet the required dimension?

Yes, unfortunately currently there is no way to check image dimensions, selected in the file input clientside.

Alright then. :ok_hand::ok_hand:

Finger crossed you’ll consider adding that validation into Wappler’s in the future. :smiley:

1 Like