简体   繁体   English

如何通过从 html 前端按下按钮使用 php 运行 .exe 文件

[英]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:这是我的 javascript 函数:

  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 :和我的 opentoide.php 文件:

 <?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. .ino 与 arduino.exe 相关联,这个文件也在 .php 文件中。 i cant seem to run the .ino file but it runs when i open it using cmd,我似乎无法运行 .ino 文件,但是当我使用 cmd 打开它时它会运行,

im not sure if its the xmlrequest is wrong or something really is wrong, can someone please help me?我不确定它的 xmlrequest 是错误的还是真的有问题,有人可以帮助我吗?

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 facepalm修复了它... demn xmlhttp 请求... 非常感谢您的帮助@IsThisJavascript 我在脚本中缺少一个 xmlhttp.send .. 非常感谢您的帮助

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");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM