web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps · Enforce Fi...
Power Apps
Answered

PowerApps · Enforce File Type on the Attachment Control

(0) ShareShare
ReportReport
Posted on by 74

Hello,

 

I would like to enforce the attaching of PDF files only, on the attachment control on my form.

 

Anyone who can help with this?

 

Thanks,

Mo'

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @momureithi ,

    Put this on the OnAddFile of the Attachment Control

    If(
     Right(
     Last(Self.Attachments).Name,
     3
     ) <> "pdf",
     Notify(
     "You can only attach PDF files",
     NotificationType.Error
     );
     Reset(Self)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • momureithi Profile Picture
    74 on at

    Hello @WarrenBelz,

     

    This has really helped. Thank you! 👍

  • SumanthDundi7 Profile Picture
    219 on at

    @WarrenBelz , Can you please suggest the formula to accept .pdf,.xls and .doc files?

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    @SumanthDundi7 ,

    You just need to add them

    <> "pdf" || <> "doc" || <> "xls"

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • SumanthDundi7 Profile Picture
    219 on at

    Thank you @WarrenBelz 

  • Community Power Platform Member Profile Picture
    on at

    Hi Warren,

     

    Above solution is working for me on PDF file only but i am getting error on 

    <> "pdf" || <> "doc" || <> "xls"

    below types. Please suggest me how do i use other formats as well in my code 

  • AdamH Profile Picture
    567 on at

    @WarrenBelz 

     

    Hi Warren - what would your suggestion be for:

    pfd, xls, xlsx, doc, docx, 

    So allowing for the 3 & 4 digit file extensions. 

     

     

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    @AdamH ,

    Simply add them all in

  • AdamH Profile Picture
    567 on at

    @WarrenBelz 

     

    Ok - I thought 

     Last(Self.Attachments).Name,
     3
     ) <> "pdf",

    was looking at the last 3 of the file extension, for example i was thinking it would see: pfd, xls, lsx, doc, ocx, instead of pfd, xls, xlsx, doc, docx, 

  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    @AdamH ,

    No, it is looking at the last 3 characters - you can actually do this another way - just keep adding them.

    If(
     !( Lower(
     Last(
     Split(
     Last(Self.Attachments).Name,
     "."
     )
     ).Value in ["pdf", "docx", "xlsx"]
     )),
     Reset(Self);
     Notify(
     "Only pdf, Word and Excel files allowed",
     NotificationType.Error,
     5000
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard