我正在尝试在服务器上的PHP中运行youtube-dl
用于下载视频的Shell脚本。我的代码如下所示:
<form action="download.php" method="get">
<input type="text" name="link"><br>
<input type="submit">
</form>
和我的download.php
样子是这样的:
<?php
$link = escapeshellarg($GET["link"]);
$output = shell_exec('/Applications/MAMP/cgi-bin/youtube-dl ' .$link. ' 2>&1');
echo "<pre>$output</pre>";
?>
因此,当我在表单中插入链接时,它将链接传递给shell_exec并使用该链接运行命令,但是我得到的是:
Usage: youtube-dl [OPTIONS] URL [URL...]
youtube-dl: error: You must provide at least one URL.
这意味着该命令未收到来自GET的链接。我该如何解决?
GET参数通过$ _GET-variable访问。注意“ GET”之前的下划线。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句