cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
G99
Post Prodigy
Post Prodigy

Better way to allowing certain file types to be uploaded

Hi everyone,

 

I have the following set up, but for some strange reason its hit and miss.

On my attachment control I want to allow only image file types to be uploaded.

 

I have created a label (LblAttachmentWarning) and its visible property is set to:

 

If(Not(".img" || ".IMG" || ".png" || ".PNG" || ".gif" || ".GIF" || ".jpg" || ".JPG" in Concat(DataCardValue23.Attachments.Name,Name&",")),true)

 and the next buttons visible property on that screen set to:

 

!LblAttachmentWarning.Visible

This seems to randomly work, sometimes I can upload a .GIF and the next button is visible and I can sometimes upload the same image and the label stays visible, so the next button is invisible, is there a better way of achieving my goal or is there an issue in my code?

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @G99 ,

Put this on the OnAddFile of the Attachment control

With(
   {
      wExt: 
      Lower(
         Right(
            Last(Self.Attachments).Name,
            3
         )
      )
   },
   If(
      wExt <> "jpg" && wExt <> "png" && wExt <> "gif" && wExt <> "img",
      Notify(
         "Only Image files allowed",
         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.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User III
Super User III

Hi @G99 ,

Put this on the OnAddFile of the Attachment control

With(
   {
      wExt: 
      Lower(
         Right(
            Last(Self.Attachments).Name,
            3
         )
      )
   },
   If(
      wExt <> "jpg" && wExt <> "png" && wExt <> "gif" && wExt <> "img",
      Notify(
         "Only Image files allowed",
         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.

View solution in original post

Hi @WarrenBelz 

 

Tried that while in studio mode and it would not allow me to upload any file types the notification appears regardless of it being an img file type

@G99 ,

Sorry - danger of free-typing without testing.

Should be And && not Or ||- fixed on original post now.

 

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.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (63,378)