将字节数组上传到MYSQL显示空字段(没有上传?)

时间:2017-01-04 00:32:28

标签: serialization file-upload unity5

我一直在尝试编写一个用UniFileViewer打开文件的脚本,设置文件的路径并将其传递给各种方法,将其序列化并上传到我的MYSQL服务器。当我运行脚本时,它执行没有问题,但结果是0字节上传到数据库。我一定错过了这里的东西......

 public class FileOpen : MonoBehaviour
{

public UITexture ProfilePic;
public static Texture2D tex = null;
public static String selectedFilePath;

void openFile()
{
    UniFileBrowser.use.OpenFileWindow(OpenFile);

}

public static Texture2D LoadPNG(string selectedFilePath)
{

    byte[] fileData;


        fileData = File.ReadAllBytes(selectedFilePath);
        tex = new Texture2D(2, 2);
        tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.

    return tex;
           }

//打开文件并将其发送给服务器     void OpenFile(string filePath)     {         selectedFilePath = filePath;         LoadPNG(selectedFilePath);

    Texture2D uploadFile = tex;
    byte[] bytes = uploadFile.EncodeToPNG();
    string fileToSend = Convert.ToBase64String(bytes);
        string[] datas = new string[1];
        datas[0] = fileToSend;
        LoginPro.Manager.ExecuteOnServer("SaveFile", SendToServer_Success, SendToServer_Error, datas);




}

0 个答案:

没有答案