我有3个文件,一个是index.php,一个是instapic.php,另一个是instapic.sh php应该执行sh来显示图像,但是当它在“索引”网站上时它不会工作,当它被定向到/instapic.php时它工作得更早,但我希望它显示在主索引页面上。
<html>
<head>
<style>
div {
font family: Ubuntu;
background-color: #F2F2F2;
}
</style>
</head>
<body>
<div>
<h1> <center> Instagram Full Size Profile Picture </center> </h1>
</div>
<center>
<form action="" method="get">
Enter Instagram Username: <input type="text" name="input">
<input type="submit" value="View">
</form>
</center>
</body>
<?php
$name = $_REQUEST['input'];
echo $name;
echo "<br>";
$output = shell_exec("/var/www/html/instapic.sh $name");
echo "<img src=$output>";
?>
-
#!/bin/bash
NAME=$1
#curl -s https://www.instagram.com/$NAME/ | grep image | grep fbma | sed 's,s150x150/,,g' | cut -f 4 -f '"'
curl -s https://www.instagram.com/$NAME/ | grep "og:image" | sed 's,s150x150/,,g' | cut -f 4 -f '"'
答案 0 :(得分:1)
要实现这一点,您需要在索引上添加一些PHP代码,然后将表单发送到同一页面。 如果您不想每次发送ajax调用时都重新加载页面。 它可能是一个解决方案(根本不是最好的):
在index.php文件的开头包含此内容:
<?php
if(isset($_REQUEST['input'])) {
$name = $_REQUEST['input'];
$output = shell_exec("/var/www/html/instapic.sh $name");
}
>
并将其包括在您要显示图像的位置:
<?php
if(isset($output)) {
echo "<img src=$output>";
}
>
另外,不要忘记在表单
的action属性中添加“index.php”