public IEnumerator Upload() { //loadingAnim.SetActive(true); posting_msg.SetActive(true); //string post_url = Mainurl + upload_image_API; string post_url = "https://www.skillmuni.in/wsmapi/api/PostPhotoUpload/TagPhotoUpload"; //Debug.Log(BitConverter.ToString(imageBytes)); string usertext = user_text.text; string plan = plan_title.text; string level = PlayerPrefs.GetInt("game_id").ToString(); string lati = PlayerPrefs.GetFloat("LAT").ToString(); string longi = PlayerPrefs.GetFloat("LONG").ToString(); string uid = PlayerPrefs.GetInt("UID").ToString(); string oid = PlayerPrefs.GetInt("OID").ToString(); for (int a = 0; a < Bigger_count; a++) { List <IMultipartFormSection> formData = new List <IMultipartFormSection>(); formData.Add(new MultipartFormDataSection("UID", uid)); formData.Add(new MultipartFormDataSection("OID", oid)); formData.Add(new MultipartFormDataSection("EXTN", "png")); formData.Add(new MultipartFormFileSection("Media", post_image_byte[a], test.name, "image/png")); formData.Add(new MultipartFormDataSection("GCI", level)); formData.Add(new MultipartFormDataSection("Level", level_zone.ToString())); formData.Add(new MultipartFormDataSection("LATI", lati)); formData.Add(new MultipartFormDataSection("LONGI", longi)); formData.Add(new MultipartFormDataSection("DETAIL", User_text[a])); formData.Add(new MultipartFormDataSection("KEYINFO", User_plan[a])); UnityWebRequest www = UnityWebRequest.Post(post_url, formData); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); respose_text.text = www.downloadHandler.text; posting_msg.SetActive(false); statusmsg.text = "PLEASE TRY LATER!"; yield return(new WaitForSeconds(3f)); statusmsg.text = ""; imageBytes = null; statusmsg.gameObject.SetActive(false); } else { Debug.Log("Form upload complete! " + a); Debug.Log(www.downloadHandler.text); yield return(new WaitForSeconds(0.5f)); formData.Clear(); ////zone_handle.actionplan_score += 25; } } posting_msg.SetActive(false); //loadingAnim.SetActive(false); statusmsg.gameObject.SetActive(true); statusmsg.text = "PLAN SUCCESSFULLY GENERATED!"; yield return(new WaitForSeconds(2.5f)); statusmsg.text = ""; statusmsg.gameObject.SetActive(false); user_text.text = ""; plan_title.text = ""; reduce_plan.text = ""; reduce_text.text = ""; recycle_plan.text = ""; recycle_text.text = ""; User_text.Clear(); User_plan.Clear(); Bigger_count = 0; post_image_byte.Clear(); capturebtn1.gameObject.GetComponent <Image>().sprite = default_sprite; capturebtn2.gameObject.GetComponent <Image>().sprite = default_sprite; capturebtn3.gameObject.GetComponent <Image>().sprite = default_sprite; }
/// <summary> /// //capture image and while sending just check that input filed should not be blank /// </summary> public void Capture_data_post() { if (user_text.text == "" && plan_title.text == "" && reduce_text.text == "" && reduce_plan.text == "" && recycle_text.text == "" && recycle_plan.text == "" && post_image_byte.Count == 0) { string msg = "Please make your plan!"; StartCoroutine(statusmsgshow(msg)); } else { if (user_text.text != "" || plan_title.text != "") { User_text.Add(user_text.text); User_plan.Add(plan_title.text); } if (reduce_text.text != "" || reduce_plan.text != "") { User_text.Add(reduce_text.text); User_plan.Add(reduce_plan.text); } if (recycle_text.text != "" || recycle_plan.text != "") { User_text.Add(recycle_text.text); User_plan.Add(recycle_plan.text); } int text_count = User_text.Count; int plan_count = User_plan.Count; int image_count = post_image_byte.Count; Bigger_count = Mathf.Max(text_count, plan_count, image_count); Debug.Log(Bigger_count); Debug.Log("iimage count:" + post_image_byte.Count); if (post_image_byte.Count == 0) { for (int a = 0; a < Bigger_count; a++) { byte[] blank = new byte[1]; post_image_byte.Add(blank); test = new Texture2D(128, 128, TextureFormat.RGB24, false); test.name = "test" + a + ".png"; Debug.Log(test.name); } } else if (post_image_byte.Count < Bigger_count) { int a = Bigger_count - post_image_byte.Count; Debug.Log("count remaing " + a); for (int b = 0; b < a; b++) { byte[] blank = new byte[1]; post_image_byte.Add(blank); test = new Texture2D(128, 128, TextureFormat.RGB24, false); test.name = "test" + a + ".png"; Debug.Log(test.name); } } StartCoroutine(Upload()); } }