WWWForm wWWForm = new WWWForm();
wWWForm.AddField(KeyTypes.imgFile,Encoding.UTF8.GetString(global.PhotoByte));
wWWForm.AddField(KeyTypes.mbInStoOdId, InputField_Text[1].text);
StartCoroutine(Www_KeyValueCookie(PathTypes.UploadStoInGoodsPicturePath, wWWForm));
public IEnumerator Www_KeyValueCookie(string pt, WWWForm wWWForm)
{
Dictionary<string, string> headers = new Dictionary<string, string>();
headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";
headers[KeyTypes.cookie] = KeyTypes.token + global.VipToken + ";";
byte[] bs = wWWForm.data;
WWW wWW = new WWW(PathTypes.IP + pt, bs, headers);
yield return wWW;
if (wWW.error != null)
{
Debug.Log(wWW.error);
yield return null;
}
OnMessage(wWW.text);
}
/// <summary>
/// 回調
/// </summary>
/// <param name="www"></param>
private void OnMessage(string text)
{
JsonData jsonData = JsonMapper.ToObject(text);
//操作失敗
if (jsonData[OnMessageKey.status].ToString() == OnMessageValueError.statuError)
{
switch (jsonData[OnMessageKey.msg].ToString())
{
case OnMessageValueError.infoError:
break;
}
}
//操作成功
else if (jsonData[OnMessageKey.status].ToString() == OnMessageValueSuccess.statuSuccess)
{
switch (jsonData[OnMessageKey.msg].ToString())
{
//上傳成功
case OnMessageValueSuccess.uploadSuccess:
break;
}
}
}