UnityEngine.WWWForm.AddBinaryData C# (CSharp) Method

AddBinaryData() private method

private AddBinaryData ( string fieldName, byte contents ) : void
fieldName string
contents byte
return void
        public void AddBinaryData(string fieldName, byte[] contents)
        {
            string mimeType = null;
            string fileName = null;
            this.AddBinaryData(fieldName, contents, fileName, mimeType);
        }

Same methods

WWWForm::AddBinaryData ( string fieldName, byte contents, [ fileName, [ mimeType ) : void
WWWForm::AddBinaryData ( string fieldName, byte contents, string fileName ) : void

Usage Example

コード例 #1
0
ファイル: TestScript.cs プロジェクト: 9bits/evaluator
    IEnumerator UploadJPG()
    {
        // We should only read the screen after all rendering is complete
        yield return new WaitForEndOfFrame();

        // Create a texture the size of the screen, RGB24 format
        int width = Screen.width;
        int height = Screen.height;
        var tex = new Texture2D( width, height, TextureFormat.RGB24, false );

        // Read screen contents into the texture
        tex.ReadPixels( new Rect(0, 0, width, height), 0, 0 );
        tex.Apply();

        // Encode texture into PNG
        byte[] bytes = tex.EncodeToPNG();
        Destroy( tex );

        // Create a Web Form
        WWWForm form = new WWWForm();
        form.AddField("frameCount", Time.frameCount.ToString());
        form.AddBinaryData("fileUpload", bytes, @"C:\images\img_file.jpg", "image/jpg");

        // Upload to a cgi script
        WWW w = new WWW(url, form);
        yield return w;
        if (!string.IsNullOrEmpty(w.error)) {
            print(w.error);
        }
        else {
            print("Finished Uploading Screenshot");
        }
    }
All Usage Examples Of UnityEngine.WWWForm::AddBinaryData