SHARE
TWEET

unity upload script

a guest Dec 18th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5.  
  6. /// <summary>
  7. /// Defines the <see cref="InventoryWindow" />
  8. /// </summary>
  9. public class InventoryWindow : MonoBehaviour {
  10.     /// <summary>
  11.     /// The startCo
  12.     /// </summary>
  13.     public void startCo()
  14.     {
  15.         StartCoroutine(UploadInventoryToWebServer());
  16.     }
  17.  
  18.     /// <summary>
  19.     /// The UploadInventoryToWebServer
  20.     /// </summary>
  21.     /// <returns>The <see cref="IEnumerator"/></returns>
  22.     internal IEnumerator UploadInventoryToWebServer()
  23.     {
  24.         string url = "http://localhost/tictacttoe/inventory/publishinventory.php";
  25.  
  26.             string filePath = Application.dataPath + "/Editor/coreInventoryData.json";
  27.              
  28.         if (System.IO.File.Exists(filePath)) {
  29.  
  30.             WWWForm form = new WWWForm();
  31.             form.AddField("fileName", filePath);
  32.            
  33.             WWW w = new WWW(url, form);
  34.             yield return w;
  35.             if (!string.IsNullOrEmpty(w.error))
  36.             {
  37.                 print(w.error);
  38.             }
  39.             else
  40.             {
  41.                 print(w.text);
  42.                
  43.             }
  44.         }
  45.     }
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top