Your Microsoft Technology Development and Consulting Experts - Operating since 2000

Location
Australia WideSydney, NSWMelbourne, VicBrisbane, QldPerth, WAAdelaide, SACanberra, ACTNorthern Rivers, NSWWollongong, NSWRichmond, VicDarwin, NT
emailconsult@officeexperts.com.au
Phone1300 102 810
Office experts logo
Contact Us

File Attachments in Power Apps: The Best Way to Do Them

Upload one file or ten from a Power Apps form straight into a SharePoint document library, with one Save button and no Base64 workarounds.

By Marcello BrocchiUpdated · 13 min read
Files flowing from a form into a libraryA Power Apps form with three attached files. A flow takes each file and saves it to a document library, where every file carries the ID of the record that was just saved.New requestTitleRoof inspectionDetailsAttach filesquote.pdfphoto.jpgscope.docxSaveFlowonce per fileDocument libraryNameParentIdquote.pdf42photo.jpg42scope.docx42other.xlsx17ParentId = 42ID from the saved record

Introduction

If you’ve ever tried to implement file attachments in Power Apps, you know it can be surprisingly challenging. You would expect attaching files to be a straightforward process, but the traditional approaches often involve complex workarounds and multiple steps for users.

The good news? Microsoft has significantly improved this process with a new action in Power Automate that makes uploading documents to SharePoint document libraries much simpler and more efficient. In this guide, I’ll show you:

  • How to add the file attachment control to your app
  • How to set up a Power Automate flow to handle file uploads
  • How to connect everything together for a seamless user experience
  • How to upload multiple files at once
  • How to show the files again, and the mistakes to avoid along the way

Prefer to watch the video?

Head over to my YouTube channel Chino Does Stuff to watch the video tutorial. There you will see a variety of videos with loads of tricks and tips on the entire Power Platform suite.

Why this approach is better

Before diving into the implementation, let’s understand why this method is superior to older approaches:

  • Simpler implementation

    No need for complex Base64 encoding or JSON manipulation. The flow receives a real file and needs a single expression to save it.
  • Multiple file support

    Easily handle multiple attachments in a single save operation. A ForAll loop sends each file to the flow in turn.
  • Better user experience

    Users can attach all files and save the record in one step.
  • Document library storage

    Files are saved to a SharePoint document library instead of list attachments, providing better management options such as extra columns, views and versioning.
  • Relationship preservation

    Maintains the relationship between files and records through a ParentId column.

How the options compare

Three ways to handle files in Power Apps
ApproachWhere files end upGood fitTrade-off
V2 trigger and a document library (this guide)A document library, linked to the record by ParentIdSeveral files per record, with real document managementNeeds a small flow and a ParentId column
Built-in list attachmentsAttached to the list item itselfSmall, simple forms with a few filesFewer document library features, such as views and extra columns
Older Base64 and JSON flowsWherever the flow saves themExisting apps that already use the patternMore expressions to build, test and maintain

What works, and what to plan for

No approach is perfect. Here is what this one handles well, and what you should allow for before you build.

Works well

  • Several files per save, sent one after another from a single button.
  • Files land in a document library that you control.
  • Each file is linked back to its record by ParentId.
  • Extra columns on the library can be filled in by the flow.
  • Users never leave the form.

Plan for

  • Files upload after the record is saved, so the record exists even if an upload fails.
  • Each file is a separate flow run, so big batches take longer to finish.
  • Size and count limits come from the control’s settings and from SharePoint itself. Check the current limits for your tenant.
  • Users need a connection to SharePoint and to the flow, so this isn’t an offline pattern.
  • The attachment control has to be borrowed from a form (see step 1).

Which option should you use?

Not every app needs a flow. Follow the questions below to match the option to your situation. If you land on the solid box, the rest of this guide is for you.

Which file storage option fits?A decision flow. If the files do not need a SharePoint document library, choose a Dataverse file column when your data is in Dataverse, otherwise the built-in list attachments. If they do, and each file must link to a record, use the Power Apps V2 trigger method with a ParentId column. Without that link, use the same flow and skip the ParentId input.Do the files need to sit in aSharePoint document library?Is your data alreadyin Dataverse?Do you need to link each fileto a record?NoYesYesNoNoYesDataversefile columnFiles stay withthe table rowList attachments(built in)Fine for small,simple casesSame flow,no ParentIdDrop the ParentIdinput and columnThis guide’smethodV2 trigger plusa ParentId column
Choosing between list attachments, a Dataverse file column and the V2 trigger method.

File attachments in Power Apps, step by step

Here is the whole build in three steps: the control, the flow, then the button that joins them.

  1. Add the file attachment control

    One quirk of Power Apps is that the file attachment control isn’t directly available in the insert menu. Here’s how to add it to your app:

    1. Insert a Form control onto your screen
    2. Connect the form to any SharePoint list (it doesn’t matter which one)
    3. Find the attachment control in the form
    4. Cut the attachment control (not the entire data card, just the control)
    5. Delete the form
    6. Paste the attachment control directly onto your screen

    After pasting, you’ll need to fix some errors in the control:

    Attachment control properties
    // After adding a Form control and selecting the attachment control:
    // Cut the attachment control and delete the form
    // Then paste the attachment control directly into your app
    
    // Fix common errors by setting these properties:
    BorderColor: Black
    Items: // Remove the reference to Parent.Default
    Tooltip: ""
    DisplayMode: DisplayMode.Edit
    
    // Additional configurations to consider:
    MaxAttachments: 10  // Set your desired maximum number of attachments
    MaxAttachmentSize: 10  // Size in MB (check the current maximum for your setup)

    The MaxAttachments and MaxAttachmentSize properties are particularly important to configure based on your requirements.

    Pro tip
    Set both limits on day one. Users then hit your limit in the app, rather than a failure in the flow.
  2. Create the Power Automate flow

    Next, we’ll create a flow that receives files from Power Apps and saves them to a SharePoint document library.

    Set up the document library

    In SharePoint, create a document library to store your attachments. Add a Number column called “ParentId”. This will store the ID of the related record from your list.

    Create the flow

    In Power Automate, create a new Power Automate flow with these steps:

    1. Trigger: Use the “Power Apps (V2)” trigger. This is crucial, as it supports direct file inputs.
    2. Create file in SharePoint: This action saves the file to your document library.
    3. Update file properties: This sets the ParentId property to associate the file with your record.
    4. Respond to Power Apps: This completes the flow and returns control to your app.
    Power Apps (V2) trigger inputs
    // In Power Automate, use the Power Apps trigger (V2)
    // Define two inputs in your Power Apps trigger.
    // Power Apps passes values in the order you add them,
    // so keep this order in step with the Run() call in your app.
    
    // Input 1: Parent ID input
    Type: Number
    Name: ParentId  // To associate the file with your record
    
    // Input 2: File input
    Type: File
    Name: File  // The name you'll reference in your flow
    Create file and update file properties
    // After the trigger, add "Create file" action
    // Select SharePoint and "Create file"
    
    Site Address: https://yourtenant.sharepoint.com/sites/yoursite
    Folder Path: /YourDocumentLibrary
    File Content: @triggerBody()['file']['contentBytes']
    File Name: @{triggerBody()['file']['name']}
    
    // Then add "Update file properties" action
    Site Address: https://yourtenant.sharepoint.com/sites/yoursite
    Library Name: YourDocumentLibrary
    Id: @outputs('Create_file')?['body/ItemId']  // Item ID from the previous action
    ParentId: @{triggerBody()['ParentId']}
    
    // Finally, add "Respond to PowerApps" action
    // No response values needed
    
    // Tip: pick each value from the dynamic content list rather than typing it.
    // The internal names can differ from the input names you chose.

    Save your flow with a descriptive name like “Save File to SharePoint”.

    Pro tip
    A clear flow name matters. It’s the name you’ll see when you add the flow to your app in step 3.
  3. Connect Power Apps to your flow

    Now we need to modify our app’s save button to handle both the record creation and the file uploads:

    Save button, OnSelect
    // In your Save button's OnSelect property:
    // First save your record and capture the ID
    Set(
        RecId,
        Patch(
            YourDataSource,
            Defaults(YourDataSource),
            {
                Title: txtTitle.Text,
                Description: txtDescription.Text,
                Priority: rdoPriority.Selected.Value
            }
        ).ID  // Extract just the ID from the returned record
    );
    
    // Then loop through all attachments and save each one
    ForAll(
        FileAttachments.Attachments,
        SaveFileToSharePoint.Run(
            RecId,  // Parent ID from the saved record
            {
                file: {
                    contentBytes: Value,  // File content
                    name: Name           // File name
                }
            }
        )
    );
    
    // Reset controls and navigate back
    Reset(txtTitle);
    Reset(txtDescription);
    Reset(rdoPriority);
    Reset(FileAttachments);
    Navigate(Home, ScreenTransition.None);

    Let’s break down what’s happening here:

    1. First, we save our record to the data source using Patch()
    2. We capture the ID of the newly created record in a variable (RecId)
    3. We use ForAll() to loop through each attachment in the FileAttachments control
    4. For each attachment, we call our flow, passing both the record ID and the file details
    5. Finally, we reset our form controls and navigate back to the home screen
    Pro tip
    Capture the ID with Set(RecId, Patch(…).ID). The flow then only runs once the record exists, and every file gets a ParentId to match.

How it all works together

When a user fills out your form and attaches files:

What happens when a user clicks SaveSix numbered steps. The app saves the record to a SharePoint list and gets the new record ID back. It then calls a flow once per file. The flow creates each file in a document library and sets its ParentId to the record ID, so a gallery can later filter the library by that ID.POWER APPSSHAREPOINT LISTPOWER AUTOMATEDOCUMENT LIBRARYON THE VIEW SCREENNew requestRoof inspectionAttach filesquote.pdfphoto.jpgscope.docxSaveRecId = 42Patch saves the record,then ForAll loops overthe files.IDTitle17Site visit42Roof inspectionPower Apps (V2)inputs: file, ParentIdCreate filesaves to the libraryUpdate file propertiessets ParentIdRespond to Power Appshands control backNameParentIdquote.pdf42photo.jpg42scope.docx42other.xlsx17Files for record 42quote.pdfphoto.jpgscope.docxParentId = IDParentId = ID123456
The numbers match the list below.
  1. They click the Save button
  2. The app saves the record data to your SharePoint list
  3. The app gets back the record ID
  4. For each attached file, the app calls your flow
  5. The flow saves each file to the document library and sets the ParentId property
  6. The files are now linked to your record by the ParentId

This entire process happens seamlessly, and the user only needs to click Save once.

Viewing attached files

To display files associated with a record, you’ll need to:

  1. Create a gallery control on your view screen
  2. Connect it to your document library
  3. Filter the gallery to show only files where ParentId matches your current record’s ID
  4. Add an icon or button to open each file

The formula for the gallery’s Items property would be something like the one below. Swap CurrentRecord.ID for whatever holds the selected record’s ID in your app, such as a gallery’s Selected.ID.

View screen
// Gallery Items property
Filter(YourDocumentLibrary, ParentId = CurrentRecord.ID)

// Open icon, OnSelect property
// (check the name of your library's link column, it is often 'Link to item')
Launch(ThisItem.'Link to item')

Other ways to handle attachments

This method is my first choice when files belong in a document library. These are the other routes, and when they make sense.

  • Built-in list attachments

    Best for: Small forms where a few files per item is enough.
    Trade-off: Files sit inside the list item, so you give up document library features.
  • Dataverse file column

    Best for: Apps that are already built on Dataverse tables.
    Trade-off: Storage and licensing differ from SharePoint, so check the details before you commit.
  • External blob storage

    Best for: Very large files, or files that other systems need to read.
    Trade-off: More to build, secure and maintain than a SharePoint library.

Best practices and considerations

When implementing file attachments in Power Apps:

  • Set sensible limits

    Be aware of SharePoint’s file size limits and set MaxAttachmentSize accordingly.
    • Set MaxAttachments and MaxAttachmentSize to the numbers you want.
    • Tell users the limits on the screen, before they pick files.
    • Where the control can’t restrict file types, check the extension in the flow.
  • Add progress indicators

    For a better user experience, add a loading spinner during file uploads.
    • Set a variable such as varUploading to true before the loop.
    • Show a spinner while the variable is true.
    • Set the variable back to false after the loop finishes.
  • Handle errors

    Consider adding error handling to deal with upload failures.
    • Wrap the ForAll loop in IfError.
    • Show a clear message when a file doesn’t upload.
    • Let the user try again, and check the flow’s run history for the cause.
  • Check permissions

    Ensure users have appropriate permissions to the SharePoint document library.
    • Give users the access they need to add files, and no more.
    • Remember the flow runs under a connection, so confirm whose.
    • Test with an ordinary user, not just an administrator.

Progress and error handling work well together. Here is the save button from step 3 with both added:

Save button with progress and error handling
// Save button: progress indicator and error handling together
Set(varUploading, true);
IfError(
    ForAll(
        FileAttachments.Attachments,
        SaveFileToSharePoint.Run(
            RecId,
            { file: { contentBytes: Value, name: Name } }
        )
    ),
    Notify("One or more files did not upload. Please try again.", NotificationType.Error)
);
Set(varUploading, false);

Advanced customisations

This approach can be extended in several ways:

  • Add file type validation in your flow
  • Create custom thumbnails for different file types
  • Implement version control for updated files
  • Add the ability to delete attachments
  • Create a preview capability for common file types

Common mistakes to avoid

These five come up again and again when file uploads misbehave. Each one is quick to fix once you know to look for it.

  • Uploading before the record exists

    If the flow runs before Patch has finished, there is no ID to use as the ParentId. The file lands in the library with nothing connecting it to a record.
    InsteadRun Patch first, capture the ID in a variable, then loop over the attachments.
  • Leaving the control on its defaults

    An unrestricted control lets someone attach a 400 MB video to a quick request, and the failure shows up later in the flow, not in the app.
    InsteadSet MaxAttachments and MaxAttachmentSize to the numbers you actually want, and say so on the screen.
  • Forgetting to reset the control

    The attachment control keeps its files after Save. Open the form again and the same files are still queued, ready to be uploaded twice.
    InsteadReset the control after a successful save, along with your other inputs.
  • Assuming every upload worked

    A flow can fail for one file and succeed for the rest. Without error handling, the user sees the happy ending anyway.
    InsteadWrap the loop in IfError and tell users what failed, so they can try again.
  • Showing the whole library

    A gallery pointed at the library with no filter shows every file for every record.
    InsteadFilter by ParentId so each record only shows its own files.

Before you share the app

  • The library has a Number column called ParentId
  • The flow has ParentId and File inputs, in the order the app calls them
  • The flow ends with Respond to Power Apps
  • MaxAttachments and MaxAttachmentSize are set
  • Save runs Patch first and captures the new ID
  • ForAll calls the flow once for each attachment
  • The control and the other inputs are reset after saving
  • Upload errors are caught and shown to the user
  • The gallery filters the library by ParentId
  • A test user can add files, and can’t see more than they should

Need a hand with file attachments in Power Apps?

We build and fix Power Apps and Power Automate solutions for Australian organisations. If your upload flow is stuck, or you’d rather have an expert set it up properly the first time, get in touch.

Frequently asked questions

Can I upload more than one file at a time?

Yes. The ForAll loop in the Save button calls the flow once for every item in the attachment control, so users can attach several files and click Save once. Set MaxAttachments to cap how many they can add.

Why can’t I find the attachment control in the Insert menu?

It only appears inside an edit form, which is why step 1 borrows it. Add a form, connect it to any SharePoint list, cut the attachment control out of its data card, delete the form, and paste the control onto your screen.

Do I need a premium licence for this?

It depends on your plan and the connectors you use. The SharePoint connector is a standard connector, but licensing changes over time, so confirm the current rules with Microsoft or your licensing partner before you build.

How do I show the files that belong to a record?

Add a gallery connected to your document library and filter it where ParentId equals the current record’s ID. Add an icon or button on each row so users can open the file.

What happens if one of the uploads fails?

The record is already saved by then, so wrap the ForAll loop in IfError, tell the user what failed and let them try again. Open the flow’s run history in Power Automate to see which step went wrong.

Conclusion

With Microsoft’s improved Power Apps V2 trigger in Power Automate, handling file attachments in Power Apps has become significantly easier. This approach provides a clean, user-friendly way to upload files to SharePoint and maintain their relationship with your app’s data.

By using a document library instead of list attachments, you gain all the benefits of SharePoint’s document management capabilities while providing a seamless experience for your users.

This method eliminates much of the complexity that was previously required for file uploads in Power Apps, making your apps more maintainable and user-friendly.

If you’d like to see more Power Apps development tips and techniques, please head over to the YouTube channel and leave a comment there. I actively monitor and respond to all YouTube comments!

Marcello Brocchi

About the author

Marcello Brocchi is a lead developer at Office Experts Group, an Australian Microsoft consultancy established in 2000. He specialises in Power Platform integration and is the founder of the YouTube channel ChinoDoesStuff. You can also find him on LinkedIn. If you have any questions, please feel free to get in contact using the form below.

Contact Us

Get in touch with our team for general enquiries and support. We're here to help with any questions you might have about our services.

Need to attach a file?

Need pricing for a specific project? Fill out our quote form and we'll provide you with a detailed estimate tailored to your needs.