Im trying to make a bug reporter but i do not know how to upload a .txt(or float if it fit in 1 script) file to a server
if anyone know, please tell me ![]()
Im trying to make a bug reporter but i do not know how to upload a .txt(or float if it fit in 1 script) file to a server
if anyone know, please tell me ![]()
allright i god something… i have this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Net;
using System.IO;
public class submitBug : MonoBehaviour
{
public InputField _name;
public Text _date;
public InputField _whatDidHeDO;
public InputField _whatHappend;
string sendedText;
string FTPHost = "ftp.box.com";
string filepath;
string FTPUsername = "secret";
string FTPPassword = "secret";
// Use this for initialization
void Start()
{
}
// Update is called once per frame
public void Submit()
{
if (string.IsNullOrEmpty(_name.text) || string.IsNullOrEmpty(_whatDidHeDO.text) || string.IsNullOrEmpty(_whatHappend.text))
{
Debug.Log("fill everything in f8ot");
return;
}
else
{
Debug.Log("uploaded :)");
Upload();
//submit here
Debug.Log(Application.persistentDataPath);
}
}
void Upload()
{
//upload
string submidedBug = _name.text + ", " + _date.text + ", " + _whatDidHeDO.text + ", " + _whatHappend.text;
System.IO.File.WriteAllText(Application.persistentDataPath + "/bugReport.txt", submidedBug);
filepath = Application.persistentDataPath + "/bugReport.txt";
WebClient client = new System.Net.WebClient();
Uri uri = new Uri(FTPHost + new FileInfo(filepath).Name);
client.Credentials = new System.Net.NetworkCredential(FTPUsername, FTPPassword);
client.UploadFileAsync(uri, "STOR", filepath);
//end uploading
}
}
but got this error:
UriFormatException: Invalid URI: The format of the URI could not be determined: ftp.box.combugReport.txt
System.Uri…ctor (System.String uriString, Boolean dontEscape)
System.Uri…ctor (System.String uriString)
submitBug.Upload () (at Assets/_scrips/submitBug.cs:50)
submitBug.Submit () (at Assets/_scrips/submitBug.cs:36)
UnityEngine.Events.InvokableCall.Invoke (System.Object[ ] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:153)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[ ] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:634)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[ ] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:769)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
UnityEngine.EventSystems.EventSystem:Update()