Beispiel #1
0
    IEnumerator PostStlToPHP(string url, PlayerDataCenter.IllNessData pd, Action <bool, string> call)
    {
        byte[] bytes = Tool.AuthGetFileData(pd.Modelpath);

        WWWForm form = new WWWForm();

        form.AddField("title", pd.title);
        form.AddField("injury_position", pd.injury_position.ToString());
        //int intposition = pd.position == PlayerDataCenter.IllNessData.Direction.Left ? 0 : 1;
        form.AddField("position", pd.position.ToString().ToLower());
        form.AddField("description", pd.description.ToString());
        form.AddField("note", pd.note);
        form.AddField("protector_shape", pd.protector_shape.ToString());

        form.AddBinaryData("stl", bytes, "3.stl");

        UnityWebRequest StlRequest = UnityWebRequest.Post(url, form);

        // StlRequest.SetRequestHeader("Content-Type", "application/json");
        StlRequest.SetRequestHeader("X-Requested-With", "XMLHttpRequest");

        yield return(StlRequest.SendWebRequest());

        string result = StlRequest.downloadHandler.text;

        if (StlRequest.isNetworkError || StlRequest.isHttpError)
        {
            call(false, StlRequest.error);
        }
        else
        {
            if (StlRequest.responseCode == 200)
            {
                call(true, result);
            }
            else
            {
                call(false, result);
            }
        }
    }