Good Day everyone,
I m building a react form with multiple files input field and some other basic fields (FirstName, LastName, Email,....). I could Post this data when the form is submitted as multipart/form-data to "When a http request is received" trigger, but not sure how to handle the output so it can be readable and send it via email and attach the files to the email too.
Any help would be appreciated!
Thanks in Advance!
Hello Everyone,
for the future viewers, I could find the solution for my scenario. so here it is:
I m creating a react form where the user will submit it with attached files - I don't know how many files - and need to upload these files to OneDrive and have them attached to email that'll be sent to the submitter, so in react:
const formdata = new FormData(event.target);
formdata.set('files', uploadedFiles.length); // numbers of files
uploadedFiles.forEach((file, index) => { // uploadedFiles comes from a function that handels the input type="file"
formdata.append('filename_'+index, file.name);
formdata.append('file_'+index, file);
});
axios({
method: "post",
url: the-post-link-you-get-from-when a HTTP Request is Received-flow,
data: formdata,
headers: { "Content-Type": "multipart/form-data" },
})
.then(function (response) { //handle success
console.log("New Post has been sent to Power Automate!");
})
.catch(function (response) { //handle error
console.log('error: '+response);
});
and in Power automate:
note: what's surrounded with red line, is just to show the expression.
next add Do Until flow:
count = variable('count')
Outputs = Outputs('Compose_-_Total_Files')
and here are the flows inside Do Until:
this is how the array should look like to set to the attachment field in send email flow later.
{ "Name": triggerFormDataValue(Outputs('Compose_-_filename_x')),
"ContentBytes": triggerFormDataValue(Outputs('Compose_-_file_x')) }
File Name: triggerFormDataValue(Outputs('Compose_-_filename_x'))
File Content: triggerFormDataValue(Outputs('Compose_-_file_x'))
then outside the Do until add Send an Email (V2), and expand the Show Advanced Options, and in the attachment set the array of the files that we created before (you need to switch the button beside the attachment from text to this one):
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2