I'm trying to implement an upload routine for huge files, for this I'm chunking the file and send chunk by chunk to server so far so good.
Now to identify the chunk-parts, I'm trying to send some more information than the pure filepart in FormData
.
var xhr = new XMLHttpRequest();
xhr.open("POST", 'upload.php', true);
var formData = new FormData();
formData.append("chunkpart", blob); // blob is Blob() or BlobBuilder
formData.append("chunkNumber", sendCount); // sendCount is an integer
formData.append("maxChunks", Math.ceil(maxChunks)); // maxChunks is a floatingpoint
formData.append("fileID", fileID); // fileID is an almost unique string
xhr.send(formData);
On the php side the chunkpart
is found in $_FILES
however chunkNumber, maxChunks
and fileID
are found in $_POST
.
My question here: Am I doing something wrong or did I just misunderstood how FormData
works and how can I get it work like I expected?