Skip to content

Instantly share code, notes, and snippets.

@yosun
Created December 29, 2017 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosun/52aa9a5e812c429bbbad4dde776f814a to your computer and use it in GitHub Desktop.
Save yosun/52aa9a5e812c429bbbad4dde776f814a to your computer and use it in GitHub Desktop.
WWWPost using UnityEngine.Networking UnityWebRequest.Post
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class WWWPost : MonoBehaviour {
public void Post(string url,WWWForm form){
StartCoroutine(PostCoroutine(url,form));
}
IEnumerator PostCoroutine(string url,WWWForm form)
{
UnityWebRequest www = UnityWebRequest.Post(url, form);
www.chunkedTransfer = false;
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
print(www.downloadHandler.text);
Debug.Log("Form upload complete!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment