WWWForm表单提交
private static string userName = "";
public static void SetUserName(string name)
{
userName = name;
}
public static string GetUserName()
{
return userName;
}
public static IEnumerator OnUpFlie(string url,byte[] bytes)
{
//创建一个Web表单
WWWForm form = new WWWForm();
form.AddField("name", GetUserName());//表单:name
int i = 0;
i ++;
string photoName = GetUserName() + i + "photograph.jpg";
form.AddBinaryData("item", bytes, photoName);//表单:item
WWW www = new WWW(url, form);
if (!string.IsNullOrEmpty(www.error))
{
Debug.Log("www.error:" + www.error);
}
if (www.isDone)
{
isUpFileSucceed = true;
responseMsg = www.text;
Debug.Log("Done" + www.text);
}
yield return new WaitForEndOfFrame();
}