When I upload a picture is around 900KB , it shows a 400bad request.
However, if I upload smaller pictures, it is okay. The way I upload it is to convert the byte into the string using JSONSerializeObject Any idea why a larger file will fail? I'm using Unity WebRequest to upload it, and in the documentation, it didn't say anything related to file size
When I upload smaller pictures around 19KB, it's successfully uploaded. I know unity supports texture using www however since I need to store multiple images on the server. So the way I do it is to open a List<byte[]> each element in the list means 1pictures. This helps me to load more than one picture when I use JSON deserialize.
Question: I want to know if it is the server setup problem or if the problem is related to the Unity web request, The server side is not written by me so the info is limited. Thank you in advance
Code for uploading
IEnumerator UploadImage()
{
WWWForm form = new WWWForm();
form.AddField("user_id", "_Pictures");
form.AddField("data", ImageData);
using (UnityWebRequest www = UnityWebRequest.Post("Example.com", form))
{
www.timeout = 100;
Debug.Log(www.uploadProgress);
yield return www.SendWebRequest();
if (www.result != UnityWebRequest.Result.Success)
{
Show_status.text = "Upload failed, please check your internet connection";
Debug.Log(www.error);
}
else
{
Show_status.text = "Image upload complete";
Debug.Log("Image upload complete!");
}
}
}