-1

i want to know what is wrong with this code,I want to run an external program through php

function thisfunction(){
    var x = new XMLHttpRequest();
    x.open("GET","plm.php",true);
    x.send();
    return false;
}

this is my php file

<?php
function _exec($cmd) 
{ 
   $WshShell = new COM("WScript.Shell"); 
   $oExec = $WshShell->Run($cmd, 0,false); 
   echo $cmd;
   return $oExec == 0 ? true : false; 
}_exec("mspaint.exe");
?>
Alex
  • 3
  • 1
  • Did you execute `thisfunction()`? What is the result? – showdev Sep 02 '16 at 17:30
  • 2
    What makes you think there *is* anything wrong with the code? Is there some indication of a problem that you've neglected to describe? – David Sep 02 '16 at 17:32
  • 1
    what are you expecting to happen? paintbrush magically shows up in the user's browser? – Marc B Sep 02 '16 at 17:35
  • Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. – Alex Sep 02 '16 at 17:36
  • And yes that i what i want to do . open an external program through php – Alex Sep 02 '16 at 17:40

1 Answers1

0

It seems you need to enable CORS.

From http://enable-cors.org/:

Cross-Origin Resource Sharing (CORS) is a specification that enables truly open access across domain-boundaries. If you serve public content, please consider using CORS to open it up for universal JavaScript/browser access.

Also read the following thread: XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP

Community
  • 1
  • 1