Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

How to post images to mysql using unity webrequest?

$
0
0
Hello i need your help, I am trying to post image data in form of Base64string to a php script. It is working on my localhost in right way.But when i am using same logics for my web server, It only works when i am posting the small size images but not working when i am posting large size images. And even if small images are posted my webrequest with async operation keeps on overlooping and never return isDone ==true. Here is my c# code public void upload() { Sprite sp = GetComponent().sprite; byte[] bytes = sp.texture.EncodeToPNG(); string imgstr = Convert.ToBase64String(bytes); WWWForm insertInfo = new WWWForm(); insertInfo.AddField("servername", dbcon.Server_name1); insertInfo.AddField("username", dbcon.Username1); insertInfo.AddField("password", dbcon.Password1); insertInfo.AddField("database_name", dbcon.Database_name1); insertInfo.AddField("data_value", "Anyone"); insertInfo.AddField("img_value", imgstr); insertInfo.AddField("data_column_name", "actual_data"); insertInfo.AddField("image_column_name", "data_img"); insertInfo.AddField("table_name", "sft_table"); tryagain: using (UnityWebRequest dataInserturl = UnityWebRequest.Post("https://myserver.com/myphpfolder/Insertinformation.php", insertInfo)) { UnityWebRequestAsyncOperation web_Async_Operation = dataInserturl.SendWebRequest(); if (dataInserturl.isNetworkError || dataInserturl.isHttpError) { Debug.LogError("Insert B Error-" + dataInserturl.error); yield return new WaitForEndOfFrame(); // goto tryagain; } while (!web_Async_Operation.isDone) { Debug.Log("Progress=" + web_Async_Operation.progress); yield return new WaitForFixedUpdate(); } rawtext0 = dataInserturl.downloadHandler.text.Trim(); Debug.LogError("Rawtext=" + rawtext0); } Here is my php Code Thank you people in advance, if you have any solution or a better idea to perform such operation than please post your solutions.

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>