Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ajax formdata append does not work for key value style

why this code does not work ? how am I supposed to append additional data in formdata?

fd = new FormData();
fd.append("file_for_upload", file_blob_chunk);
fd.append("test", "testing");
fd.append("test2", original_file_name);

xhr = new XMLHttpRequest(); 
xhr.open("POST", "files/index/" + file_name + '/' + file_part, true);
xhr.send(fd);

when I debug it, I can see the array for 'file_for_upload', but not for 'test' or 'test2'.

basicly usually you will use $_FILES and then it should show array of file_for_upload. It works that way. but now I need to add another one such as original_file_name. but it does not show the other array.

Is it possible because I only have one form for file upload in the html page, and don't have the other two textbox form?

like image 633
Harts Avatar asked Nov 03 '22 08:11

Harts


1 Answers

You will find those two in $_POST. Only files go into $_FILES.

like image 126
kapa Avatar answered Nov 11 '22 09:11

kapa