Sending Image gives 417 - Expectation Failed

Howdy y’all,

After having officially wasted the ENTIRE day trying to solve this problem by myself, I am desperately turning to the great Hive Mind.

I have a simple WWW + Form code that sends a ScreenShot taken with ReadPixels that is supposed to upload the image with a binary www action to a PHP file that, in its turn, sends it via email to me, so I can see it (For bug reporting purposes).

The WWW works, cos it sends text as well.
The PHP works, cos it sends the email and I get it.

What I get is the following error:
“You are trying to load data from a www stream which had the following error when downloading.
417 Expectation failed”

Code is as follows:

function getScreenshot(){
 	yield WaitForEndOfFrame();
	var tex = new Texture2D( Screen.width, Screen.height, TextureFormat.RGB24, false );
	Debug.Log("Created tex");
	tex.ReadPixels( new Rect( 0, 0, Screen.width, Screen.height ), 0, 0);
	Debug.Log("Read pixels");
	tex.Apply ();
	bytes = tex.EncodeToPNG();
	info = tex.ToString();
	Debug.Log("Encoded to PNG");
	cube.renderer.material.mainTexture = tex; //to check if the ReadPixels worked well
	uploadScreenshot();
}
function uploadScreenshot(){
    // Create a Web Form
    var form = new WWWForm();
    form.AddBinaryData("Screenshot", bytes, "Screenshot.png", "image/png");
    Debug.Log("Created Form");
    // Upload     
    var w = WWW(siteAddress+"SendScreenshot.php", form);
    Debug.Log("Sending Form");
    yield w;
    Debug.Log("Form came back");
    if (w.error != null) {
        Debug.Log(w.error + " - "+w.text);
    } else {
        Debug.Log("Finished Uploading Screenshot - "+w.text);
    }

And the PHP is:

<?php
    //define the receiver of the email
    $to = 'my@email.com';
    //define the subject of the email
    $subject = 'Bug Report Screenshot';
    //create a boundary string. It must be unique
    //so we use the MD5 algorithm to generate a random hash
    $random_hash = md5(date('r', time()));
    //define the headers we want passed. Note that they are separated with 

    //add boundary string and mime type specification
    $headers = "MIME-Version: 1.0" . "

“;
$headers .= “Content-type:text/html;charset=iso-8859-1” . "
“;
$headers .= “From: server@email.com
Reply-To: server@email.com”;
//$headers .= "
Content-Type: multipart/mixed; boundary="PHP-mixed-”.$random_hash.”"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
Screenshot = _REQUEST[‘Screenshot’]; //getting the file info from the WWW request
$attachment = chunk_split(base64_encode(file_get_contents($Screenshot)));
//define the body of the message.
ob_start(); //Turn on output buffering
?>

--PHP-alt-<?php echo $random_hash; ?>--

--PHP-mixed-<?php echo $random_hash; ?>--

header('Content-type: image/png');
header('Content-Disposition: attachment; filename=Screenshot.png');
header('Content-Transfer-Encoding: binary');

<img src=data:"<?php echo $attachment; ?>" alt="Bug report image" />

//<?php echo $Screenshot; ?>
//<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--

<?php
    //copy current buffer contents into $message variable and delete current output buffer
    $message = ob_get_clean();
    //send the email
    $mail_sent = @mail( $to, $subject, $message, $headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
    echo $mail_sent ? "Mail sent" : "Mail failed";
    ?>

Now that I do not have anymore hair left on my head, I turn to you.
Please, help me!

1 year later I know, but I was hairless with these stuff too, and got answers just right now…
For those getting “Recv failure: Connection was aborted” or “417 - Expectation Failed” without reason, it only happens in the Editor, and probably only with AddBinaryData() usage. Compile it and run on server/local and everything should work fine, like here.
Regards.