Restricting users to specified file types in Attachment control
This is a fairly straight-forward, but useful function to restrict users uploading attachments to file type specified. The example below restricts to JPG or PNG, but could be anything you choose. As soon as a non-allowed file is uploaded, it is immediately deleted and a message displayed regarding allowed file types. This code needs to go at OnAddFile in the Attachment control.
With(
{
_Type:
Last(
Split(
Last(Self.Attachments).Name,
"."
)
).Value
},
If(
!(_Type in ["jpg", "png"]),
Notify(
"Only JPG or PNG files Allowed",
Error
);
Reset(Self)
)
)
You could also set a more prominent message label visibility off a variable triggered in the bottom If() statement if the Notification ribbon at the top is not sufficient.