简体   繁体   中英

php exec function on xampp work in windows but not on linux

Few months ago I make this c++ code in Visual studio on Windows. I make .exe file from that code and everything work fine. Now I trying to do same thing on Linux so that I can put executable file on Linux web server. My linux executable file work if is called from console. But I can't run executable file over browser. This work for me on xampp windows:

<?php
$imagename = $_GET['imagename'];
exec('inpainting.exe' .$imagename); 
echo "<img src=\"./images/img-uploads/ob_img$imagename.jpg\" />";
?>

How to run it on xampp linux? I made new execute file for linux and name of that file is just inpainting_linux

You're lacking a space:

exec('inpainting.exe'.$imagename);  
                    ^-- here

meanding that given a query string of (say) kittens.jpg , you'll be executing:

inpainting.exekittens.jpg
             ^^---note lack of space

which is pretty much absolutely guaranteed to produce a "no such file or command" error.

And note my comment above. You're absolutely BEGGING to get your server destroyed or at least pwn3d remotely with this code. do NOT run this code on a publicly accessible server. Or better yet, take the code out back and burn it.

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