Back to all posts
PowerApps

Convert Attachments to Base64 in Power Apps

April 22, 20267 min read
Convert Attachments to Base64 in Power Apps

Working with attachments in Power Apps can become surprisingly difficult once you move beyond basic scenarios.

Uploading a file is easy.

But the moment you need to:

  • send attachments to external APIs
  • integrate with Azure services
  • store files in SQL databases
  • process documents in Power Automate
  • build enterprise-grade integrations

πŸ‘‰ the default Attachments control quickly becomes limiting.

In this guide, you’ll learn how to convert attachments to Base64 in Power Apps using Power Fx. This gives you full control over file content and allows you to send files anywhere β€” APIs, Azure Blob Storage, Power Automate, custom backends, SQL, or Dataverse integrations.

Why Base64 Matters in Enterprise Apps

Base64 encoding is extremely useful in enterprise Power Platform solutions where files need to move across multiple systems.

Instead of relying only on SharePoint-specific attachment behavior, Base64 gives you a portable representation of the file that can be:

  • sent to REST APIs
  • stored in Azure Blob Storage
  • processed in Power Automate
  • passed into custom backend services
  • stored in SQL or Dataverse
  • used in AI or document processing scenarios

This approach creates significantly more flexible integration scenarios compared to the default Attachments control.

Important Considerations

While Base64 provides excellent flexibility, there are a few things to keep in mind:

  • Base64 increases file size by roughly 33%
  • Very large files can impact Power Apps performance
  • Always validate file size before processing
  • Always validate file type before upload
  • Consider Azure Blob Storage for enterprise-scale storage scenarios

For small and medium-sized attachments, this approach works extremely well and provides far more flexibility than the default attachment handling experience.

The Problem

The default Attachments control is useful for simple scenarios, especially when working with SharePoint forms.

But it becomes limiting when you need more control.

You quickly run into issues like:

❌ Hard to send files to external APIs

❌ Tightly coupled with SharePoint

❌ Limited control over file content

❌ Difficult to reuse in custom integration scenarios

❌ Not ideal for Azure, SQL, or custom backend integrations

And that becomes a blocker when building real-world business applications.

Why This Matters

In enterprise apps, attachments are rarely just β€œfiles”.

They are often part of a larger process:

  • invoice approval
  • document upload
  • inspection reporting
  • image capture
  • customer onboarding
  • AI document processing
  • ERP or CRM integration

In these scenarios, you often need to:

  • send files to external APIs
  • store them in Azure
  • pass them into Power Automate
  • process them in a custom backend
  • save metadata separately
  • connect files to business records

πŸ‘‰ And for that, you need full control over the file data.

The Idea: Convert Attachments to Base64

Instead of relying only on the default behavior of the Attachments control:

πŸ‘‰ convert the file to Base64

This gives you:

βœ” full control over the file content

βœ” ability to send files anywhere

βœ” independence from SharePoint attachments

βœ” better integration options

βœ” reusable file handling logic

Once the file is converted to Base64, you can send it to:

  • Power Automate
  • REST APIs
  • Azure Blob Storage
  • Azure Functions
  • SQL databases
  • custom backend services
  • Dataverse integrations

Step 1: Add an Attachment Control

Start by adding an Attachment control to your Power Apps canvas app.

Image1

If you cannot find the Attachments control, that is expected.

πŸ’‘ The Attachments control is normally available inside forms.

Workaround

  1. Create an Edit Form
  2. Connect it to any data source
  3. Add the Attachments field
  4. Copy the Attachments control
  5. Paste it directly into your screen
  6. Remove the temporary form if you no longer need it

This gives you access to the attachment upload experience without being fully dependent on the form layout.

Step 2: Get the Attachment Content

Now you need to access the uploaded file content.

One simple approach is to use a hidden Image control.

Image2)

Set the Image property of the Image control to:

First(AttachmentControl.Attachments).Value

Image3)

This gives you access to the binary content of the first uploaded attachment.

If your attachment control allows multiple files, you can later extend this approach by looping through the attachments collection.

Step 3: Convert the File to JSON

Next, convert the file content into JSON format using the JSON() function.

Set(
    varAttachmentJson,
    JSON(
        ImageControl.Image,
        JSONFormat.IncludeBinaryData
    )
)
JSONFormat.IncludeBinaryData

This tells Power Apps to include the binary file data inside the JSON output.

The result is a string that contains metadata and Base64 content.

Step 4: Extract the Base64 Content

The JSON output includes a prefix before the actual Base64 content.

Usually, it looks similar to this:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...

In many integration scenarios, you only need the clean Base64 part.

To extract it, use:

Set(
    varBase64Only,
    Mid(
        varAttachmentJson,
        Find(",", varAttachmentJson) + 1,
        Len(varAttachmentJson) - Find(",", varAttachmentJson) - 1
    )
)

πŸ‘‰ Now you have clean Base64 data stored in:

varBase64Only

This variable can now be sent to Power Automate, APIs, Azure services, or any custom backend.

Step 5: Capture the File Name

In most real-world scenarios, the file content alone is not enough.

You usually also need the file name.

You can get it from the attachment control:

Set(
    varFileName,
    First(AttachmentControl.Attachments).Name
)

Now you have:

varFileName
varBase64Only

This gives you both the file name and the Base64 file content.

Step 6: Use the Base64 File Anywhere

With varBase64Only, you can integrate attachments with almost any system.

For example, you can:

  • send files to REST APIs
  • store files in Azure Blob Storage
  • pass attachments to Power Automate
  • save files in SQL
  • send files to Azure Functions
  • process files with AI
  • connect documents to business records

Image6)

This is where Power Apps becomes much more than a form builder.

It becomes part of a real integration architecture.

Real-World Use Cases

This approach is especially useful for scenarios like:

  • sending invoices to external ERP APIs
  • uploading documents to Azure Blob Storage
  • integrating with AI document processing services
  • processing files in Power Automate
  • building enterprise approval workflows
  • storing attachments outside SharePoint
  • sending inspection photos to custom APIs
  • connecting files to Dataverse records
  • creating document automation solutions

These scenarios are very common in enterprise Power Platform projects.

What You Get

Once you implement this approach, you get:

βœ… Full control over attachment content

βœ… Ability to send files to any API

βœ… Flexibility to use Azure or custom backend services

βœ… Better control over file metadata

βœ… Less dependency on SharePoint attachment behavior

βœ… A reusable pattern for enterprise Power Apps solutions

Why This Is Powerful

This removes one of the biggest limitations in Power Apps.

You are no longer tied only to:

  • SharePoint attachments
  • built-in attachment behavior
  • form-specific limitations

Instead, you control the file data.

You decide where the file goes.

You decide how it is processed.

You decide how it fits into your architecture.

That is a very different level of flexibility.

Best Practices

When working with attachments and Base64 in Power Apps, I recommend following these best practices:

  • validate file size before processing
  • validate file type before upload
  • avoid processing very large files directly in the app
  • store large files in Azure Blob Storage
  • store metadata separately in Dataverse or SQL

This makes the solution easier to maintain and much more scalable.

Final Thoughts

Handling attachments properly unlocks a lot of possibilities in Power Apps.

Power Apps becomes significantly more powerful once you stop treating it as only a form platform.

With techniques like Base64 conversion, Power Platform can integrate with APIs, Azure services, AI solutions, and enterprise backends in ways that go far beyond standard low-code scenarios.

This is where Power Apps starts becoming a true enterprise application platform.

The Rule to Remember

If you need flexibility with files in Power Apps:

πŸ‘‰ convert attachments to Base64.

It gives you control, portability, and integration flexibility.

One Question

How are you handling attachments in your apps today? πŸ‘‡