I send the script to the php file using XMLHttpRequest and FormData. Actually, the question is, how can I send some other data like IDs along with the files?

const request = new XMLHttpRequest(); const formData = new FormData(); request.open('POST', 'composer/upload_photo.php'); formData.append('photo', file); request.send(formData); 

    1 answer 1

    Everything is just like adding another value to the form, and depending on the sending method, get them either from POST or GET, and the file from FILES

     formData.append('id', id); 
    • I've tried. But he didn’t understand how to get it later ... - Vyacheslav Mikhailov
    • And what language do you write backend? Everything personally and works for me personally. - Shnur
    • he realized with a fresh mind, and got out of $ _POST, sat before that, and did not understand why the ID was not in $ _FILES ... Thank you - Vyacheslav Mikhailov
    • Yes, from $ _POST or $ _GET you need to get depending on the method of delivery)))) - Shnur