How to use WWWForm.AddBinaryData() properly.

So I have a 2-Dimensional Array and I want to add it as a blob data in my mysql database.

I'm using WWWForm.AddBinaryData but I can't seem to get it through to php. Any help is appreciated :).

        BinaryFormatter bf = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();
    byte[] dataArray = ms.ToArray();

    WWWForm form = new WWWForm();

So that is the c# part, can anyone please help me with the PHP part? Thanks in advance.

You should also post your PHP script but my first guess would be that you are not handling the file right for the binary data on the PHP side. Sending binary data to the php page acts just like uploading a file via an HTML page's POST acts essentially. So you must get the temp file's path from the $_FILES global. From there you need to do something with it such as reading it to a variable with fopen/fread. After that you can then pass the binary data to your mySQL database's BLOB field.

Another thought to consider that held me up as well. Is that when submitting the WWWForm make sure that it is running in a coroutine so that all the data can be uploaded fully. When I was attempting to upload a few megabytes worth of data it would sometimes not transfer the entire block if not spun off in a coroutine.

just print the data in php file using this command


you will get the complete list of global array along with file upload data