JS Byte Array to File on PHP Side

Viewed 735

I have a Uint8Array which have 10000 bytes on Javascript side.

var data = new Uint8Array(10000) ;

I want to send it to PHP and create a file with it:

    $.ajax({
        url:'saver.php',
        type: 'POST',
        contentType: 'application/octet-stream',  
        data:data,
        processData: false
    });

This ajax is sending data (I see it on "Request Payload" section on console) but there is no $_POST record, $_POST array is empty, just silent. How to grab it properly?

2 Answers

In my case. I get binary file from JS request array : $file['content'] format of Uint8Array.

            <?php
            $packed = pack("c*", ...$file['content']);
Related