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


  $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');";
    echo "DataEntered";


Unity code for inserting data

string IGRMSDataEntryCode="";
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()
    if(artifactidField.text=="" || artifactnameField.text=="" || artifactdescriptionField.text=="")
        messagebox.text="All fields are mandatory";
    else {


public void IGRMSDataReset()


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";
  • \$\begingroup\$ 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? \$\endgroup\$ – Philipp Apr 2 '16 at 10:11
  • \$\begingroup\$ image files selected by the user from the system \$\endgroup\$ – user1509674 Apr 2 '16 at 10:55
  • \$\begingroup\$ 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#? \$\endgroup\$ – Philipp Apr 2 '16 at 10:59
  • \$\begingroup\$ that part I havent done.Could you please help me out \$\endgroup\$ – user1509674 Apr 2 '16 at 11:00
  • \$\begingroup\$ 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#? \$\endgroup\$ – Philipp Apr 2 '16 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.