In this PowerApps tutorial, we will discuss how to upload a file or a document to SharePoint Online Document Library using PowerApps. Let us see, PowerApps upload file to SharePoint document library.
For this, we will also use the Microsoft Flow or Power Automate.
Also, We will see these below things as:
- How we can upload and tag multiple files to SharePoint Document Library using PowerApps Attachment control
- PowerApps upload files to SharePoint Library using Power Automate/Microsoft Flow
- PowerApps upload files to SharePoint Document Library with a different type of SharePoint columns
- PowerApps upload file to sharepoint document library
- PowerApps upload attachment to sharepoint
- Powerapps upload excel file to sharepoint
- Powerapps upload multiple files to sharepoint
- upload multiple files from PowerApps to sharepoint document library
- Powerapps upload multiple files to sharepoint
- Powerapps upload image to sharepoint
- upload a file to sharepoint from PowerApps
PowerApps Upload File to SharePoint Library
Let us see first how to upload file to SharePoint document library in PowerApps.
In my SharePoint Online Site, I have a SharePoint Document Library named TSInfo Documents. This library has these below columns as:
- Name: By default, it is a single line of text column.
- Modified: It is a Date and Time Data type column.
- Modified By: Person or Group Data type column.
- Document Type: It is a Choice Data type column having some choice values.
- Department: It is also a Choice Data type column having some choice values.

- Here in this scenario what I want to do is, When a user will press a Powerapps button, then it will upload a single file or multiple files (like excel file, ms documents, image file, pdf file, etc) to this SharePoint Document library (TSInfo Documents).
- As I have seen many posts, most of the people are using the PowerApps Add picture control to upload the files in the SharePoint Document Library.
- Normally, When you will add an Add picture control to the Powerapps screen, by default, it appears with a Button and image control that looks like below:

- Once you will click or tap the control, then it will ask you to upload your desire files from your local system.
- But here the problem is when you will upload any file, every time you need to change the File options to All Files, and then you can select any types of files (like image file, pdf file, excel file, etc.) from your system.

- It is such an irritating thing that every time you need to select the All Files option to upload different types of files in Powerapps. To avoid this type of problem and make it to as simple, I will use the PowerApps Attachment control.
- In the case of PowerApps Attachment control, you do not need to change the File options, directly you can attach any files (image file, pdf file, ms documents, etc) from your local system and use it as like the below screenshot:

Read Power Automate create an HTML table
Upload multiple files to SharePoint Document Library using PowerApps Attachment Control
Now, let us see how to upload multiple files from powerapps to sharepoint document library.
As we discussed above, the easiest way to upload multiple files to SharePoint Document Library, We can use the PowerApps Attachment Control. But the main thing we need to know is how we can add an Attachment control in the Powerapps screen as there is no Powerapps inbuilt control that we can find out in the app.
To add an Attachment control on the PowerApps screen, We need to follow the below things:
- Go to View tab -> Data sources -> Search SharePoint -> Add a new or existing connection -> Select the SharePoint site -> Choose any SharePoint list (you can take any SharePoint list) -> Click on Connect button. Then the specific SharePoint list has been added to the app.
- Next, insert an Edit form (Insert -> Forms -> Edit). Select the edit form and go to the Properties pane (from the right side of the page). Select the Data source as your SharePoint List (Company Info).
- Once you will add the SharePoint list data source, you can able to see an attachment control has been added to the edit form automatically as shown below.

- Just select the attachment control and unlock it. Now just copy the attachment data card (Select the data card -> right-click on it -> click on copy) and then paste (right-click -> Paste) it in the outside of the edit form.

- Once you pasted the attachment control, you can remove the edit form from the app. As the form is not needed further so that we can remove it (we need only the attachment control).
- Rename the Attachment control to AttachFiles as like below. You can see some error will appear in the Attachment control. Once you will click on the error symbol, then you can see what are those errors appear in some of the attached properties.
- You can edit the error from the formula bar and just remove it and make all those blank.

- Now the attachment control is ready to attach any type of file. Save and Preview (F5) the app.
- Click on Attach file link from the attachment control. It will ask you to attach the file from your local system. You can attach any file to the Attachment control.
- The benefit is, you do not need to make the File option as All Files during each and every time of attaching the file.

Create PowerApps Attachment Collection
- Now we will create a PowerApps collection that will help to store all the files at the time of attaching.
- Select the Attachment control (Attach Files) and apply this below formula on its OnAddFile properties as:
OnAddFile = ClearCollect(attachCollection, AttachFiles.Attachments)
Where,
- ClearCollect = Collect is the Powerapps function that helps to create the Powerapps collection. The ClearCollect function will always clear the previous values and take the recent values
- attachCollection = Powerapps Collection name where the attach files will store
- AttachFiles = Powerapps Attachment control name

- Similarly, go to the OnRemoveFile properties and apply the same formula as in the above properties (OnAddFile).

- Save and Preview the app. Attach some different types of files using the Attach file option.
- Once you attached, then open the Powerapps Collections (View -> Collections -> attachCollection). Here, you can see the attached files will store with two different categories as:
- Name: It specifies the file name that I have uploaded.
- Value: It is not a Datastream. Its a URL to local blob storage in Powerapps where it is maintaining the reference to the file. As this is a link, so we can not pass this value to flow because flow cannot understand the link and it can not convert into Binary.
For that, We need to create a Data stream that should contain an image of the file. If we will create a Datastream, then the flow will understand and it will easily convert into Binary format to upload the file into SharePoint.

To create a Data stream we need to add a Picture control where we can get the Data stream. Follow the below things that we needs to do:
- Create a PowerApps Gallery control and add the collection Data source that you have created recently. (Select the gallery -> Go to Properties pane -> Select attachCollection from Data source)
- Select the Title field of the gallery control and rename the Title to lblTitle. Similarly, select the Image field and rename it to imgDataStream.
- Select the image field or control from the gallery. Image control should be ThisItem.value. Because the Value has the link to the local blob storage.

- As it is an image file, so I need to attach an image to the attachment control and then we can see the image in the gallery control.

- Now we do not need the gallery control. So we can hide it from the Powerapps screen (select the Gallery -> Properties -> toggle off to Visible property).
- Insert a Button (Insert -> Button) and set its Text property to Upload Files to SharePoint Library.
- As we need to create the Datastream from the gallery control itself (because it is having the image control), that’s why we will create another collection in the PowerApps Button. So that instead of Value, we can get the Datastream from the collection.
- Select the Button (Upload Files to SharePoint Library) and apply this below formula on its OnSelect property as:
OnSelect = Clear(colAttachmentGallery);
ForAll(
Gallery1.AllItems,
Collect(
colAttachmentGallery,
{
Title: lblTitle.Text,
DataStream: imgDataStream.Image
}
)
);
Where,
- colAttachmentGallery = PowerApps Collection Name
- Gallery1 = PowerApps Gallery control name
- lblTitle = Label control name that is present inside the gallery control
- imgDataStream = Image control name that is present inside the gallery control

- Save and Preview the app. Attach some files (including image files) from your local system and then hit on the button (Upload Files to SharePoint Library).
- Go to the PowerApps Collections and open the new collection (colAttachmentGallery). Now you can see there are two columns available named DataStream and Title as shown below.

PowerApps Upload File to SharePoint Library using Flow
Now its time to create a Power automate or flow that will help you to upload a single file or multiple files to SharePoint Document Library. Follow these below steps to create a flow from PowerApps app and use in PowerApps.
Step-1:
- On the PowerApps screen, select the PowerApps Button (Upload Files to SharePoint Library) -> Go to Action tab -> Power Automate -> + Create a new flow.

Step-2:
- Go to My flows (from the left navigation) -> Click on +New tab (from top) -> Select + Instant–from blank -> Enter a name for the flow (Upload Files to SharePoint Library) -> Choose PowerApps to trigger the flow -> Hit on Create button.

Step-3:
- Next, the new flow will open with the PowerApps action (because you have chosen PowerApps to trigger the flow). Add a new step and insert an Initialize variable action under the PowerApps action. Enter these below field values as:
- Name: Type a name for the variable (varUploadFiles).
- Type: Select the type as String from the dropdown.
- Value: Go to the Dynamic content tab and click on Ask in PowerApps option. Whenever I called this flow from Powerapps, this is the value that the flow will expect Powerapps to pass. It is expecting a String value that is coming from the PowerApps.

Step-4:
- Insert a Compose action below the Initialize variable and enter the Inputs value as:
- Inputs: Go to the Expression tab and apply the formula as json(variables(‘varUploadFiles’)). Where varUploadFiles is the variable name (from the Initialize variable action). Here we are converting the Powerapps variable to JSON format.

Step-5:
- Now just save the flow and go back to the PowerApps app. Add that flow to the PowerApps button (Upload Files to SharePoint Library). Select the button -> Go to Action tab -> Power Automate -> click on the flow name (Upload Files to SharePoint Library) -> flow will be added to the button.
- Once the flow will add to the button, then it will appear as “UploadFilestoSharePointLibrary.Run()” where UploadFilestoSharePointLibrary is the flow name.
- Add the below formula on Button’s OnSelect property as:
OnSelect = UploadFilestoSharePointLibrary.Run(JSON(colAttachmentGallery,JSONFormat.IncludeBinaryData))
Where,
- colAttachmentGallery = Collection name that contains Title and as well as the Data stream value.
Below screenshot is for your reference.

Step-6:
- Now just Preview the app and click on the Button (Upload Files to SharePoint Library) and then go to the flow.
- Open the Flow Run History (My flows -> Select the flow -> Click on ellipses -> Run history). You can see your flow is recently succeded. Open that succeded flow and expand the Compose section as below. Copy the full code from the Output section (we will use this code in the next action).

- Edit the flow and insert the Parse JSON action below the Compose action. Enter the below filed values as:
- Content: Go to Dynamic content tab -> Select the Outputs under the Compose section.
- Schema: Click on Generate from sample option -> Paste the code that you have copied from the Compose Output section. Once you will paste the code, you can see there are two properties available i.e. one is a DataStream and another one is Title.

Step-7:
Next, we will add Apply to each control action under the Parse JSON. Because of the Parse JSON is going to give you an array of object, that’s why we need to apply this control.
- Select an output from previous steps: Go to Dynamic content tab -> Select the Body from the Parse JSON action.

Step-8:
Inside the Apply to each control action, click on Add an action link and insert the Create file action (in SharePoint) as shown below. Enter the field values as:
- Site Address: Provide the specific SharePoint site address URL.
- Folder Path: Select the SharePoint Document Library (from the Show picker icon) where you are going to upload the Powerapps files.
- File Name: Select the Dynamic content -> choose Title under the Parse JSON section.
- File Content: Go to the Expression tab and apply the formula as dataUriToBinary(items(‘Apply_to_each’)[‘DataStream’])

Step-9:
- That’s it for the Powerapps flow. Below screenshot represents the total structure of the Microsoft Powerapps flow that we have recently created.

- Now just save the flow and go back to the Powerapps app. Select the button (Upload Files to SharePoint Library) and copy the whole formula (from OnSelect property) and remove it. Again add the flow to the button and paste the same formula on its OnSelect property as like below:

Step-10:
- Save and Preview (F5) the app. Attach some files (different types of files as image file, Excel file, pdf file etc) to the Powerapps Attachment control. Next, click on the button to upload the files to the SharePoint Document Library.
- Now check the flow run history, you can see the flow has been completed successfully as shown below. Also, if you will expand the Apply to each action branch, then you can analyze that, it has run 4 times because the output action of JSON has 4 files that I posted from Powerapps to flow.
- Then it will create the file one by one in the SharePoint Document Library (TSInfo Documents).

- Next, Open the SharePoint Online Document Library (TSInfo Documents). Then the library will appear with all those four Powerapps files that you have attached in the attachment control as below. You can open any file once you click on it.

PowerApps Upload Files to SharePoint Library with different types of Columns
Let us see how to upload multiple files from PowerApps to SharePoint document library.
- Suppose in SharePoint Document Library, you want to add some extra file information like Document Type, Document Created Date, Department, etc. Then, in that case, you can insert all different types of SharePoint Data columns by using the PowerApps flow.
- As you can see in my SharePoint Document Library (TSInfo Documents), I have associated with more two columns as Document Type and Department. Both columns are Choice Data type having with these below choice values as:
- Document Type: [Private, Public, Confidential, Internal]
- Department: [TRAINING, IT, HR, FINANCE]
- Here what I want to do is, When I will upload the Powerapps files to SharePoint library, at the same time, both choice column values (Document Type and Department) also will add including those files.
- Follow these below things that we needs to do:
Step-1:
- Go to the PowerApps app. On the Powerapps screen, Insert two Dropdown controls (Insert -> Input -> Drop down) for two-choice columns.
- Rename the two dropdown controls to ddDocType and ddDepartment as shown below.
NOTE:
As above are the Choice columns, thats why I have inserted the Dropdown control in Powerapps. Similarly, if there is a Date Time column in SharePoint Library, then you should take a Date Picker control. Also, if there is a text column in SharePoint library, then you should take a Text input control.

Step-2:
- Now its time to connect the SharePoint Document Library to Powerapps app. Because we need the SharePoint choice values in the Powerapps Dropdown control.
- That means, when a user will click the dropdown control, then he/she can able to see all the choice values that are coming from the existing SharePoint Document Library.
- Now to connect the SharePoint Data source connector, Go to View -> Data sources -> search SharePoint -> Add a new or existing SharePoint connection -> Select the SharePoint Site -> Choose the SharePoint Document Library (TSInfo Documents) -> Hit on the Connect button. Then the specific SharePoint Document Library will be added as shown below.

Step-3:
Next, we need to add all the choice values (from SharePoint Library) to the dropdown controls.
- Select the Document Type Dropdown control and set its Items property as:
Items = Choices('TSInfo Documents'.'Document Type')
- Similarly, Select the Department Dropdown control and set its Items property as:
Items = Choices('TSInfo Documents'.Department)
You can refer this below screenshot.

Step-4:
Open the PowerApps flow that you have recently created. Insert an Initialize variable action below the first Initialize variable (that you created for the files). We need to add this variable action for the Document Type choice column. Enter these below field values as:
- Name: Specify a name for the variable (varDocumentType).
- Type: Select the type as String from the dropdown.
- Value: Go to the Dynamic content tab and click on Ask in PowerApps option under the PowerApps section.

Step-5:
Similarly, add another Initialize variable under the Initialize variable 2 action. We need to add this variable action for the Department choice column. Enter these below field values as:
- Name: Specify a name for the variable (varDepartment).
- Type: Select the type as String from the dropdown.
- Value: Go to the Dynamic content tab and click on Ask in PowerApps option under the PowerApps section.

Step-6:
Next, Insert an Update file properties (in SharePoint) action under the Create file action (in apply to each control section). Fill the field values as:
- Site Address: Provide the SharePoint Site address URL.
- Library Name: Select the SharePoint Document Library (TSInfo Documents) from the Dropdown.
- Id: Go to the Dynamic content and select the ItemId from the Create file section.
- Document Type Value: Go to the Dynamic content -> Select varDocumentType under the Variables section.
- Department Value: Go to the Dynamic content -> Select varDepartment under the Variables section.

Step-7:
Now that’s it for doing in the Power Automate. Just Save the flow. This below screenshot represents the total Power Automate structure that I have created to upload the files to SharePoint library.

Step-8:
- Now come back to the PowerApps app. Select the button (Upload Files to SharePoint Library), then copy and remove the code from its OnSelect property.
- Again add the flow to the PowerApps button and paste the code with some more values (on its OnSelect property) like below:
OnSelect = Clear(colAttachmentGallery);
ForAll(
Gallery1.AllItems,
Collect(
colAttachmentGallery,
{
Title: lblTitle.Text,
DataStream: imgDataStream.Image
}
)
);
UploadFilestoSharePointLibrary.Run(
JSON(
colAttachmentGallery,
JSONFormat.IncludeBinaryData
),
ddDocType.Selected.Value,
ddDepartment.Selected.Value
)
Where,
- ddDocType = Document Type Dropdown control name
- ddDepartment = Department Dropdown control name

Step-9:
- Save and Preview the app. Attach some files (different types) to the Attachment control.
- Select the Document type and any Department values from the Dropdown control.
- Click on the Button (Upload Files to SharePoint Library).
- Once you will go to the flow and open the Flow run history, then you can see your flow has been succeeded.

Step-10:
- Now open the SharePoint Document Library (TSInfo Documents). You can see all the Powerapps files have been uploaded including with Document type and Department values as shown below.
NOTE:
Do not forget to delete all the files from the SharePoint Library before you upload again from Powerapps. Otherwise, you may confuse with the uploaded files.
Also, if you forgot to delete the files from the SharePoint library, then attach some new different files in the PowerApps Attachment control and then upload it.

Also, you may like these below PowerApps Tutorials:
- Create PowerApps Date filter
- PowerApps Gallery Control Filter Example
- PowerApps Get Current User (ID, EMail, Department, Location, Photo, etc)
- PowerApps send email on submit
- PowerApps Microphone Control – How to use
- How to Create Login Screen in PowerApps
- PowerApps Popup message Box with Examples
- Get users from SharePoint Group in PowerApps
- PowerApps camera control + Save captured image in SharePoint
- PowerApps role based security SharePoint example (SharePoint Groups)
- Microsoft Lists – Detailed Tutorial
In this PowerApps Tutorial, We discussed how to upload a file or a document to SharePoint Online Document Library using PowerApps.
Also, We will saw these below things as and ask questions to all your queries:
- How we can upload and tag multiple files to SharePoint Document Library using PowerApps Attachment control
- PowerApps upload files to SharePoint Library using Power Automate/Microsoft Flow
- PowerApps upload files to SharePoint Document Library with a different type of SharePoint columns
- PowerApps upload file to sharepoint document library
- PowerApps upload attachment to sharepoint
- PowerApps upload excel file to sharepoint
- PowerApps upload multiple files to sharepoint
- upload multiple files from PowerApps to sharepoint document library
- PowerApps upload multiple files to sharepoint
- PowerApps upload image to sharepoint
- upload a file to sharepoint from PowerApps
I am Bijay a Microsoft MVP (8 times –Â My MVP Profile) in SharePoint and have more than 15 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Great article, thank you. However, I’m experiencing an issue with Step #8. While attempting to add the File Content parameter to the Create File action. I’ve followed your labeling and instructions so I’m using the same names, etc.
When I attempt to add this text to the File Content field:
dataUriToBinary(items(‘Apply_to_each’)[‘DataStream’])
I receive an error message stating “The expression is invalid”. What am I missing?
I ran into the same problem. I got around it by choosing Dynamic Content and then choosing the DataStream value from Parse JSON and it appeared to work, at least it copied the files. I need to do some more testing though to see if that will cause some other problem.
I’m having same issue. Were you able to resolve?
I think the problem is that you’re cutting and pasting from this website, and the ‘ character gets transformed into an incorrect character. Try manually replacing those and see if it works better for you.
I had a similar issue, turns out I had to remove some characters, following this guide: https://powerusers.microsoft.com/t5/Building-Power-Apps/Flow-to-pull-images-to-SharePoint/td-p/841999
Good article – but my flow fails at Step 10
The Automate step ‘PowerApps’ give the following error “InvokerConnectionOverrideFailed. Failed to parse invoker connections from trigger ‘manual’ outputs. Exception: Could not find any valid connection for connection reference name ‘shared_sharepointonline’ in APIM tokens header.”
And the same error is also on the buttons. Any assistance welcomed.
Problem Sorted – had to drop connection via the Action tab in Power Apps save it and add it again. Here’s the helping URL https://powerusers.microsoft.com/t5/Building-Power-Apps/PowerApps-error-when-workflow-is-run-quot/td-p/491911
Glad the issue has been resolved.
Hi, do you know maybe how to reset/clear attachments control after uploading files?
Hi,
Can you check out this article https://www.spguides.com/powerapps-email-attachment-control/
This tutorial was a life saver, thank you!
Thanks, it helps!
Brilliant! An absolute lifesaver. After days of looking around and trying to figure this out, your guide is the first one that ties everything together. I used a Logic App instead of a flow, made a few tweaks, and I have files flying into my Azure file share now. I will never understand why microsoft makes this as convoluted as possible. Thanks again!
Hello.
Thank you for a simple guide on how to upload files to a document library using flow. Unfortunately, in step 8, the flow ends with an error:
Unable to process template language expressions in action ‘Create_file’ inputs at line ‘1’ and column ‘8023’: ‘The template language function’ dataUriToBinary ‘expects its parameter to be formatted as a valid data URI. The provided value ‘appres: // blobmanager / 493b8d139c8b4c34a1c798e8f48faf7d / 3’ was not formatted correctly. Please see https://aka.ms/logicexpressions#dataUriToBinary for usage details. ‘.
I think you might have missed the step where you need to convert that blob pointer to the image data stream. An easy clue is the string should not start with “appres: // blobmanager…”, but rather something like “data:image…”
Hope that helps point you in the right direction.
This article is great, thanks for the help doing something pretty difficult
Thanks Lee!
does it allow to upload a file larger than 25MB since attachment control has size restriction?
How would you update the meta data individually for these files? I’ve created a gallery to edit the varfields for each attachment file but I don’t know how to get the update properties to update each correlated file with their new data.
After a few typos, I got my act together and this worked as you explained. I appreciated the thorough portrayal! Many thanks for your inestimable help Bijay
NIce post here, how do we delete a file from the SP library based on the file removed from the attachmentBox from powerapps then update the library with the remaining files.
Hi,
Is there any way we can see the thumbanail of the file attached and uploaded?
Hi
Do you know if its possible to upload images to a specific folder that you suggested in Powerapps, i want to put my images in a folder i select in powerapps, mainly because we will be uploading images to different folder each time.
Thanks for any help in Advance.
Just add another input field in PowerApps Trigger and add param with your path for example /Folder/OtherFolder and use dynamic content instead of Folder from Create file action
Hello, good afternoon, I get an error when opening the document uploaded to SharePoint online, why would it be?
Same issue as above. Attachment control and flow works but the file opens blank. I’ve tried jpeg and pdf files and have opened in sharepoint and tried downloading first. All open blank. I looked at the data stream, but can’t find anything wrong?
You have set the “Image” property in the Gallery to ThisItem.Value
Gracias por el articulo. Una consulta, el flujo me tira error en la acción Compose: InvalidTemplate. Unable to process template language expressions in action ‘Compose’ inputs at line ‘0’ and column ‘0’: ‘The template language function ‘json’ parameter is not valid. The provided value ‘adj’ cannot be parsed: ‘Unexpected character encountered while parsing value: a. Path ”, line 0, position 0.’. Please see https://aka.ms/logicexpressions#json for usage details.’.
Qué puede ser?
This article is great!!! I have adopted our SharePoint/PowerApps processes and I am “green” and do not have any formal training in these subjects. This has helped a lot!!
If I could ask one question. To further this process, I would like to create a button to launch the attachment. I assume using the launch command? I am having some trouble. If you have any advice, I would appreciate it!
Having some issues, I’m still getting the appress://xxx value off the Image attribute from the gallery image.
It worked!!!
Hi There, I’m not getting the attachment data card when attaching the edit form to a sharepoint library. any suggestions?
hi I tried the above flow I am getting this error. please let me know how to fix this
“Failed to parse invoker connections from trigger ‘manual’ outputs. Exception: Could not find any valid connection for connection reference name ‘shared_sharepointonline’ in APIM tokens header.”
Hello and thank you for this tutorial. It is exactly what I need for an awards app where people can submit nominations. What I’d like to do is have the nominations and supplemental documents saved to a Sharepoint list and library, but obviously I do not want anyone except the administrators of these awards to have access to this information. If I follow the steps of this tutorial, will it work if I do not share the Sharepoint site with the people submitting the form and uploading the documents? The data source about the awards in in sql and implicity shared, but the nomination data needs to be private. Any help on how to design this securely would be appreciated.
Hi, Bijay!
I have a Dataverse table as BookingTables and I have enabled Notes and Files for that table.
and I have added Attachments in the form (Which is available when you Turn on Enabled Notes and Files)
On Submit, I am submitting Form Data to Dataverse and Attachment to Notes and then Using flow to Move the Attachments from Notes to SharePoint Document Library
and I have also updated the SharePoint Library File with the Dataverse GUID to relate it.
Now, I want to show this file in my Edit form in Attachment Control (which is of Dataverse Table).
Please help