How to send data with photo using form data to a php server?

sendAttachments(attachmentArray){
  let attachments = attachmentArray
  
 attachments.forEach(async(element, i) =>{
    let Element = JSON.parse(element.attachment) //parsing JSON string into an array of objects
    Element = JSON.parse(Element) //parsing JSON string into an array of objects
    let LocalUri = Element.localUri
    let filename = Element.filename
    let type = Element.type
    // let itemnum = JSON.stringify(i+1)
    let formData = new FormData();
    // formData.append('details', {itemNo:itemnum});
    formData.append('attachment', {uri: LocalUri, name: filename, type});

     return await fetch(x+'recieveAttachments.php', {
        method: 'POST',
        contentType: false,
        processData: false,
        body: formData,
        header: {
          'content-type': 'multipart/form-data',
        },
      });
})

}

I am using this code to send an array of attachments to a server, and recieving the data in the server side using this php code below and it is getting uploaded one by one into the upload folder of htdocs.

<?php

$fileName = $_FILES['attachment']['name'];
move_uploaded_file($_FILES['attachment']['tmp_name'], "upload/".$fileName);

I am trying to make a report submission app in which I submit reports of a subject under which there are chapters respective to each chapter one would submit their report chapter wise.

I want to store them in this way in the server

expo question (2)

In this “8” is the subject code and “1” is the chapter number.

I just want to send the Subject code and Chapter number along with the attachment form data, so that I can create the directory to store the fille into that directory. Can someone tell me how I can send the Subject code and Chapter number in the form data and how to recieve it in the php code. I tried appending the Subject code and Chapter number with the formdata but it did not work out, tried sending it replacing the name but the picture did not get sent in the right format.