Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have done a sample to insert and retrieve data from MySQL in unity.Now I need to insert and retrieve image from MYSQL in unity. The images are files selected by the user from their filesystem.

Can anybody please help me?

Below is the sample code for inserting data

<?php

  $database = mysql_connect('localhost', 'root', 'amma') or die('Failed to connect: ' . mysql_error());
    mysql_select_db('igrms_db') or die('Failed to access database');
    $query="INSERT INTO igrmsdata(id,name,description) VALUES('$id','$name','$description');";
    //$query="INSERT INTO igrmsdata(id,name,description) VALUES('100','Tippu','Welcome to Tippu');";
    $result=mysql_query($query);
    echo "DataEntered";

 ?>

Unity code for inserting data

string IGRMSDataEntryCode="http://192.168.173.243/IGRMSDataEntry.php";
public InputField artifactidField;
public InputField artifactnameField;
public InputField artifactdescriptionField;
public Text messagebox;
public static string artifactid="";
public static string artifactname="";
public static string artifactdescription="";


void Start () {

}

// Update is called once per frame
void Update () {

}
public void IGRMSDataEntryDetailsDB()
{
    artifactid=artifactidField.text;
    artifactname=artifactnameField.text;
    artifactdescription=artifactdescriptionField.text;
    if(artifactidField.text=="" || artifactnameField.text=="" || artifactdescriptionField.text=="")
    {
        messagebox.text="All fields are mandatory";
    }
    else {
        StartCoroutine(AddArtifacts(artifactid,artifactname,artifactdescription));
    }

}

public void IGRMSDataReset()
{

    artifactidField.text="";
    artifactnameField.text="";
    artifactdescriptionField.text="";
    messagebox.text="";
}


IEnumerator  AddArtifacts(string id,string name,string description)
{

    //string register_url = getscoreCode + "?name=" + user + "&score=" + scor;
    string register_url = IGRMSDataEntryCode + "?id=" + id + "&name=" + WWW.EscapeURL(name) + "&description=" + WWW.EscapeURL(description);

    WWW entereddata = new WWW (register_url);
    yield return entereddata;
    messagebox.text="Data Uploaded Successfully";
    artifactidField.text="";
    artifactnameField.text="";
    artifactdescriptionField.text="";
}
share|improve this question
    
If you would post your data saving code we could better tell you how to modify it to store image data. Also, what kind of image data are you talking about? Raw images? Render textures? Image files selected by the user from the file system? – Philipp Apr 2 at 10:11
    
image files selected by the user from the system – user1509674 Apr 2 at 10:55
    
So where is your code? Also, can I assume that you already know how to open the file picker dialog and read a binary file with c#? – Philipp Apr 2 at 10:59
    
that part I havent done.Could you please help me out – user1509674 Apr 2 at 11:00
    
I would like to help you, but it's hard when you are so uncooperative. Again: Can I assume that you already know how to open the file picker dialog and read a binary file with c#? – Philipp Apr 2 at 11:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.