I have a Byte array delcared:
public Byte[] clipArray;
After filling the array, I post it to a web form like this:
string url = "removed for privacy/security";
WWWForm form = new WWWForm();
form.AddBinaryData("soundArray", clipArray);
Debug.Log(clipArray.Length);
WWW www = new WWW(url, form);
StartCoroutine(WaitForRequest(www));
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// check for errors
if (www.error == null)
{
Debug.Log("WWW Ok! - result: " + www.data);
} else {
Debug.Log("WWW Error: "+ www.error);
}
}
On the php side, I use $_REQUEST to get the array:
$soundFileArray = ($_REQUEST["soundArray"]);
$soundFileName = "sound.wav";
$fh = fopen($soundFileName, 'w');
fwrite($fh, $soundFileArray);
fclose($fh);
However, when I run the program, the sound.wav file is empty. The byte array doesn’t seem to be passed. What am I doing wrong?