hi
i am trying to upload screenshot to server using this code
#pragma strict
var screenShotURL= "http://www.d**";
var skaitlis:int;
// Take a screen shot immediately
function Start () {
//UploadPNG();
}
function UploadPNG () {
// We should only read the screen after all rendering is complete
yield WaitForEndOfFrame ();
// Create a texture the size of the screen, RGB24 format
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D ( width, height, TextureFormat.RGB24, false );
// Read screen contents into the texture
tex.ReadPixels ( Rect(0, 0, width, height), 0, 0 );
tex.Apply ();
// Encode texture into PNG
var bytes = tex.EncodeToPNG ();
Destroy ( tex );
// Create a Web Form
var form = new WWWForm ();
form.AddField ( "action", "Upload Image" );
form.AddBinaryData ( "fileUpload", bytes, "screenShot"+skaitlis+".png", "image/png" );
// Upload to a cgi script
var w = WWW ( screenShotURL, form );
yield w;
if (w.error != null) {
print ( w.error );
} else {
print ( "Finished Uploading Screenshot" );
}
}
function OnGUI(){
if (GUI.Button(Rect(10,10,50,50),"spied")){
UploadPNG();
skaitlis++;
}
}
everything works fine, no problem at all
now i am trying to upload screenshot form Mega Grab
i just dont know haw can i asses this TexData array(it is more like noob qvestion) and do someting like this
form.AddBinaryData ( "fileUpload", TexData, "screenShot"+skaitlis+".png", "image/png" );
oh i need help whit this so bad 🙁
|