Hi guys, I’m using UniFileBrowser to set filepaths and LoginPro to upload the files to the server, I have a script which is working just fine - without errors - and the debug log seems to check out - it loads a png, converts it to a base64 string and then uploads it. However when I check the database, the field where the string is supposed to be saved is empty… Anyone have any ideas?
public class FileOpen : MonoBehaviour
{
public UITexture ProfilePic;
public static Texture2D tex = null;
public static String selectedFilePath;
void openFile()
{
UniFileBrowser.use.OpenFileWindow(OpenFile);
Debug.Log("opening filebrowser");
}
public static Texture2D LoadPNG(string selectedFilePath)
{
byte[] fileData;
fileData = File.ReadAllBytes(selectedFilePath);
Debug.Log(fileData);
tex = new Texture2D(2, 2);
tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.
return tex;
}
//OPENS THE FILE AND SENDS IT TO THE SERVER
void OpenFile(string filePath)
{
selectedFilePath = filePath;
Debug.Log("Showing selected filepath" + filePath);
LoadPNG(selectedFilePath);
byte[] bytes = tex.EncodeToPNG();
Debug.Log("Encoding to png and setting to string" +bytes);
string fileToSend = Convert.ToBase64String(bytes);
Debug.Log("Converting to Base64 and setting to string" +fileToSend);
string[] datas = new string[1];
datas[0] = fileToSend;
Debug.Log("This should be the string tha gets uploaded" +datas[0]);
LoginPro.Manager.ExecuteOnServer("SaveFile", SendToServer_Success, SendToServer_Error, datas);
}