I know that the WWW or WWWForm class should be used in conjunction with a server side script such as PHP, but I can not get it to work. I am basically doing this:
var www : WWW;
var form = new WWWForm();
form.AddField("frameCount", Time.frameCount.ToString());
www = WWW(url, form); //upload to script
yield www;
Where "url" is a PHP script in the cgi-bin folder on the server where the webplayer is. The PHP script is:
<?php
$filename = 'test.txt';
$Content = "Add this to the file
";
$handle = fopen($filename, 'x+');
fwrite($handle, $Content);
fclose($handle);
?>
I know I am not using "frameCount", but I do not know of an alternative way to put WWW in POST mode. Anyway, this does not produce "test.txt" or write to "test.txt" if I create the file on the server. What am I doing wrong? I know I have access to the PHP script in Unity because I can display its contents in GUIText using the following:
var www : WWW = new WWW (url);
var form = new WWWForm();
yield www; // Wait for download to complete
if (www.error != null)
this.GetComponent(GUIText).text = www.error;
else
this.GetComponent(GUIText).text = www.text;