简体   繁体   中英

PHP exec() not running .exe unless both in same directory in XAMPP

I'm trying to using PHP to execute an .exe on my testing XAMPP server. However I can't seem to get an output from exec unless the .exe is in the same folder as the PHP file. PHP is located in /xampp/htdocs/mapping and I want to put the exe in /xampp/cgi-bin

<html>
    <body>

<?php
    exec("c:\xampp\cgi-bin\hello.exe", $output1);
    exec("/cygdrive/c/xampp/cgi-bin/hello.exe", $output2);
    exec("hello.exe", $output3);
    print_r($output1);
    print_r($output2);
    print_r($output3);
?>

    </body>
</html> 

The output is this

Array ( ) Array ( ) Array ( [0] => Hello World! ) 

I think your PHP is running in "safe mode":

Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

See:

http://www.php.net/manual/en/function.exec.php

More info on safe mode:

http://www.php.net/manual/en/features.safe-mode.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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