Kharlo Cariaga
Kharlo Cariaga

Reputation: 63

How to run a .exe file using php with a press of a button from html frontend

Im having hard time to make this work,

This is my javascript function:

  function OpenINO()
  {
  var xmlhttp;
  xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange=function()
  {
    if(xmlhttp.readyState==4 && xmlhttp.status==200)
    {

    }
  }

  xmlhttp.open("POST","Arduino/RIKDuino/opentoide.php",true);
  }

and my opentoide.php file :

 <?php 
 exec('RIKDuino.ino')
 ?> 

i even tried:

  <?php 
  exec('C:\[myfilepath]\RIKDuino.ino')
  ?> 

the .ino is asociated with arduino.exe and this file is inside the .php file too. i cant seem to run the .ino file but it runs when i open it using cmd,

im not sure if its the xmlrequest is wrong or something really is wrong, can someone please help me?

Upvotes: 2

Views: 431

Answers (1)

Kharlo Cariaga
Kharlo Cariaga

Reputation: 63

facepalm fixed it... demn xmlhttp request... Thank you so much for your help @IsThisJavascript i was missing a xmlhttp.send on the script.. thank you so much for your help

heres the final code for the script if someone needs it someday,

function OpenINOTest()
{


var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
    if(xmlhttp.readyState==4 && xmlhttp.status==200)
    {

    }
}
   xmlhttp.open("POST","Arduino/RIKDuino/opentoide.php",true);
   alert('Code Uploaded to IDE, Ide Will start Soon.')
   xmlhttp.send("fowk");
}

Upvotes: 1

Related Questions