How to send 2 requests in HTML / Javascript?

I currently have a form that uploads file to a server the files are uploaded using the regular “multipart/form-data” and method=“POST”. I also am sending additional metadata to the server in the same post. For this I hook on to the on submit event and set the value of a hidden field with the data using javascript.
All this works perfectly fine and on the server I can see the metadata and also the uploaded files in PHP.

But now I need something different. I want to send the data first to the server and then then file upload. So is there some way I can send the metadata first and then trigger the file upload submit?
I am doing this is that just in case the client upload large files and the upload fails I may not get the important metadata.

I have never tried this, but I noticed somebody asked something similar on the old forums:

I am not too familiar with PHP anymore, so my default idea is to try sending the metadata post-request using JavaScript. Would that be something you’d want to try?