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

Community site session details

Session Id : h/qZfgtnkhteT8dz32zFdu
Power Apps - Building Power Apps
Answered

Special Characters in attachments file name

Like (0) ShareShare
ReportReport
Posted on 20 Oct 2023 14:06:35 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?

I have the same question (0)
  • LindseyT Profile Picture
    20 on 20 Oct 2023 at 15:25:05
    Re: Special Characters in attachments file name

    That worked! Thank you SO MUCH!

  • Verified answer
    BCBuizer Profile Picture
    22,280 Super User 2025 Season 2 on 20 Oct 2023 at 15:21:50
    Re: Special Characters in attachments file name

    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 20 Oct 2023 at 15:05:46
    Re: Special Characters in attachments file name

    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

  • ANB Profile Picture
    7,184 Super User 2025 Season 2 on 20 Oct 2023 at 14:19:45
    Re: Special Characters in attachments file name

    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


  • BCBuizer Profile Picture
    22,280 Super User 2025 Season 2 on 20 Oct 2023 at 14:13:55
    Re: Special Characters in attachments file name

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete