- Home /
 
 
               Question by 
               supremegrandruler · Mar 22, 2018 at 10:38 AM · 
                wwwfileuploadhttphttpwebrequest  
              
 
              How to upload a file from Android to my own website?
I have my own website and am trying to upload a file to it from an Android unity app.
This is my code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class TestScript : MonoBehaviour
 {
     void Start()
     {
         StartCoroutine(Upload());
     }
 
     IEnumerator Upload()
     {
         byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data");
         UnityWebRequest www = UnityWebRequest.Put("http://***myWebsite/myFolder/myNestedFolder", myData);
         yield return www.SendWebRequest();
 
         if (www.isNetworkError || www.isHttpError)
         {
             Debug.Log(www.error);
         }
         else
         {
             Debug.Log("Upload complete!");
         }
     }
 }
 
               The problem is that it's returning a Generic/Unknown HTTP error.
               Comment
              
 
               
              Your answer