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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Special Characters in ...
Power Apps
Answered

Special Characters in attachments file name

(0) ShareShare
ReportReport
Posted on by 20

Hello!

 

I have a canvas app with a form that allows users to upload attachments. The issue is that users upload attachments that have special characters in the file name, and then they are not successfully saved to the SharePoint. Is there a way to show an error message when the file name of a chosen attachment includes a special character before it can be submitted in the app?

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at

    Hi @LindseyT ,

     

    In this topic you can find how to detect special characters: https://powerusers.microsoft.com/t5/Building-Power-Apps/Special-Characters-IsMatch-Formula-no-longer-working/m-p/2197893

     

    By using this in the OnSelect property of Upload button (or anything similar), you can show an error:

    If(
     IsMatch(FileName,".*[\\\""<>!@#$%^&*].*"),
     Notify("No special characters in filename please", NotificationType.Error),
     <Upload file>
    )

    FileName should be replaced with a reference to the control/object that has the filename and <upload file> should be replaced with the formula you currently have to upload files.

  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @LindseyT You can use IsMatch function.

     

     

    ForAll(
     NameOfTheAttchmentControl.Attachments As var,
     If(
     IsMatch(
     var.Name,
     "([_^+&\-\/()])",
     MatchOptions.Contains
     ) && !IsEmpty(NameOfTheAttchmentControl.Attachments),
     ClearCollect(
     col_IssueInFileName,
     {Name: var.Name}
     )
    ));
    If(CountRows(col_IssueInFileName)>0, Notify("Invalid Name", NotificationType.Error), UploadCode)

     

     

     

    So, basically, I am considering that you have are allowing multiple attachments. And I am using these "([_^+&\-\/()])" characters as invalid. You can add your own characters. So, if any file name contains these character, then that file name is added into collection and if the CountRows of that collection is more than 0 then you can thrown the error.

     

    You can have modify this code as per your requirement.

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    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.👍

    Thanks,
    ANB


  • LindseyT Profile Picture
    20 on at

    Thank you for the response! I am having an issue with the "FileName" you mention above. The datacard is called "AttachmentsComponent" and the only thing I can get to come up is "AttachmentsComponent.Attachments" but this doesn't seem to be looking at the text in the filename from what I can see. Is there a different AttachmentsComponent.XXX that I should be looking for?Attachments Form.jpg

  • Verified answer
    BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at

    Hi @LindseyT ,

     

    Assuming tha AttachmentsComponent is a regular Attachments control, the below should work:

     

    If(
     "Error" in ForAll(
     AttachmentsComponent.Attachments,
     If(
     IsMatch(
     ThisRecord.Name,
     ".*[\\\""<>!@#$%^&*].*"
     ),
     "Error"
     )
     ),
     Notify("No special characters in filename please", NotificationType.Error),
     <Upload file>
    )
    

     

  • LindseyT Profile Picture
    20 on at

    That worked! Thank you SO MUCH!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard