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 / Unable to convert the ...
Power Apps
Unanswered

Unable to convert the binary data from attachment control to base64 string

(0) ShareShare
ReportReport
Posted on by 3

Hi All,

 

I am kind of a newbie in PowerApps. I have tried a few solutions from the community but could not find a solution that would work. I have an attachment control where I want to be able to add multiple images at a time. I was able to get everything set up and the data is being saved in the backend SQL server properly. However, I have another column which is basically a base64 string of the same binary image. I tried this code but it is not showing up the entire base64 string. For some reason, it is only showing one line. 

 

 

ClearCollect(varCollections, ForAll(AttachmentControl.Attachments, {
image: Value
, image_base64: Mid(JSON(Value, JSONFormat.IncludeBinaryData), 25, Len(JSON(Value, JSONFormat.IncludeBinaryData))-25)
,requester_email: User().Email}))

 

This is the front-end. I created a gallery which shows the binary and base64 along with the image. Gallery is connected to the attachment control. The second line is image_base64 but it is not showing the entire base64 string. Any idea?

 

hkay_0-1697341248188.png

 

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

    Hi @hkay ,

    Put in an Image Control (you can hide it) with the Image

    Last(AttachmentControlName.Attachments).Value

    then run the JSON on that.

     

    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

  • hkay Profile Picture
    3 on at

    Hi @WarrenBelz , 

    Thank you so much for the solution. It partially worked. I was able to save the images as base64 in the backend. The only problem is when I put this in the ForAll to save the data, it is only saving the last image from the image control in the backend. I am not sure how to go around this. Here is the updated query.

    ClearCollect(varCollections, ForAll(AttachmentControl_1.Attachments, 
     {image: Value
     ,image_base64: Mid(JSON(Image5.Image, JSONFormat.IncludeBinaryData),24,Len(JSON(Image5.Image, JSONFormat.IncludeBinaryData))-24)
     ,requester_email: User().Email}));

     

     

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

    @hkay ,

    You are correct, you cannot do this within a ForAll statement. 

    The hidden image is a workaround (the Attachment Control is designed to be attached to a list), but if you want to send them out to a Flow, they need to be one at a time as far as I am aware.

    The only other thing possible with them all is to send as email attachments as that connector is compatible with the storage structure (but not suitable for what you are doing)

     

    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

  • MooFeR Profile Picture
    on at

    A simple fix is instead of doing ClearCollect on your button, to do a Collect on the attachment control's OnAddFile property. You can even use Reset(Self) at the end of OnAddFile since you don't need the file there as it's in your gallery now.

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard