423
Views
9
Comments
Solved
upload image validation

how to validate image jpg or png type not pdf type or other 

2025-04-17 05-42-16
Ajit Kurane
Solution

Hello Bijay,

I have created a small in reactive.

https://personal-xyog61l7.outsystemscloud.com/validationIMAGE/imagedemo?_ts=637762275875707408

Please find the updated OML.

Regards,

Ajit Kurane.

validationIMAGE.oml
2021-06-02 20-50-04
Márcio Carvalho
Solution

You need to do this.

Get the file size, calculate to MB and then make a condition

Check the OML in these steps

You can test here on this link!

https://marcio-carvalho4.outsystemscloud.com/validationIMAGE/imagedemo?_ts=637762597100759025


Kind Regards,

Márcio

validationIMAGE.oml
2021-06-02 20-50-04
Márcio Carvalho

Can this help you? This post has great answers to validate image jpg or png. You have an example

https://www.outsystems.com/forums/discussion/70062/how-can-add-validation-for-uploading-files/

Or you can use this asset to validate image jpg or png whether it is an image or not.

https://www.outsystems.com/forge/component-overview/7202/file-type-file-extension

You have another solution to see if is an image or not, in this case, you can compare and it says by using the binary data:

https://www.outsystems.com/forums/discussion/75039/how-i-can-check-if-the-binary-data-is-equal-to-image/

Here you have a way to see the file size:

https://www.outsystems.com/forums/discussion/61167/how-to-get-upload-file-size/

Its a lot of topics to put in this answer, please let me know if it helped you :)

Kind Regards,

Márcio

2021-11-28 09-24-08
Bijay Nayak

thank you it was helpful but what i should do about size of the image file validation.image file cant be greater than 1 mb. 

2021-06-02 20-50-04
Márcio Carvalho
Solution

You need to do this.

Get the file size, calculate to MB and then make a condition

Check the OML in these steps

You can test here on this link!

https://marcio-carvalho4.outsystemscloud.com/validationIMAGE/imagedemo?_ts=637762597100759025


Kind Regards,

Márcio

validationIMAGE.oml
2025-04-17 05-42-16
Ajit Kurane

Hello Bijay,

Hope you are doing well.

Please add below condition using if widget in your flow,

If(Index(Upload1.Filename,".png")<>-1,True,
If(Index(Upload1.Filename,".jpg")<>-1,True,False))




Hope it helps you.

Regards,

Ajit Kurane.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

file extensions can (although not common) have any combination of upper and lower case characters, furthermore jpg sometimes are also stores as jpeg. So your logic will not work in all situations.
You need to use the optional ignoreCase: True property of the Index function.

2025-04-17 05-42-16
Ajit Kurane
2025-04-17 05-42-16
Ajit Kurane
Solution

Hello Bijay,

I have created a small in reactive.

https://personal-xyog61l7.outsystemscloud.com/validationIMAGE/imagedemo?_ts=637762275875707408

Please find the updated OML.

Regards,

Ajit Kurane.

validationIMAGE.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Ajit,

I'd like to add a remark that is completely unrelated to the topic of this post : inside an If widget, there's no need to add an If statement.

i.m.h.o. readability would be improved to have this inside your if widget

Index(Upload1.Filename, ".png", ignoreCase : True) > -1
or Index(Upload1.Filename, ".jpg", ignoreCase : True) > -1
or Index(Upload1.Filename, ".jpeg", ignoreCase : True) > -1

the result of this is already a boolean, so no need to do an If(condition, True, False), that doesn't add anything.

Dorine

2021-11-28 09-24-08
Bijay Nayak

but what can i do about the size part.image file cant be greater than 1 mb.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.