通过php中的浏览器在表单提交上执行Bash脚本

时间:2017-10-25 09:02:10

标签: php html bash

我正在尝试通过php中的浏览器执行bash命令(在系统中打开应用程序)。

(示例)如果我在终端中运行命令,它会打开Shotwell(图像查看器)并显示图像。

我想在提交表单时使用shotwell在我的系统中显示图像。我该怎么做?

这是我的代码。为什么不起作用?

form.php的

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
 if(isset($_POST['submit']))
 {
        exec('shotwell bike.jpg');
 }
}
?>
<html>
<body>
<form  action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method=post>
  Store ID:<br>
  <input type="text" name="username" required>
  <br>
  Department ID:<br>
  <input type="text" name="emailID" required>
  <br><br>
  <input type="submit" name="submit" value="Submit">
</form>

</body>

0 个答案:

没有答案