wkhtmltoimage 和 PHP 调试
我正在尝试使用 wkhtmltoimage 来抓取屏幕。它不起作用,但我不知道如何调试它。我联系了我的服务器管理员,他们说允许 exec
。这是我的目录结构:
-index.php
-lib/
-screenshot.php
-wkhtmltoimage/
-wkhtmltoimage-i386
-wkhtmltoimage-amd64
screenshot.php
中的代码如下:
function screenshot($url, $save_path, $zoom = 0.5, $width = 500)
{
$zoom = escapeshellarg($zoom);
$width = escapeshellarg($width);
$url = escapeshellarg($url);
$save_path = escapeshellarg($shell_path);
print_r(scandir("lib/wkhtmltoimage"));
$output = array();
echo exec("./lib/wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("lib/wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("./wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("./lib/wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("lib/wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("./wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
echo exec("wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
print_r($output);
die();
}
index.php 在 url“http://www.nasa.gov/”上调用函数 snapshot。
这是我得到的输出:
Array
(
[0] => .
[1] => ..
[2] => wkhtmltoimage-amd64
[3] => wkhtmltoimage-i386
)
Array
(
)
显然,我什至不确定错误来自哪里。可能是路径错误,或者输入以某种方式错误,但我不知道如何获得这些因素的任何输出。即使该函数似乎也没有通过我的数组返回任何输出行。
我该如何调试这个?我从哪里开始?是否有用于检查目录或文件执行情况的 PHP 函数?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
愚蠢的错误,我不得不使用根路径。 (例如
/home/...
)是否有人也觉得 Web 开发中有一半的时间浪费在解决路径问题上?咕噜。
Stupid mistake, I had to use the root path. (e.g.
/home/...
)Does anyone also feel like half of the time in web development is wasted in solving path problems? Grrr.