如何使用PHP的wkhtmltoimage

时间:2015-01-03 16:57:58

标签: php output wkhtmltoimage

我希望当我运行从网站上拍摄的图片的php文件时,会出现在php文件中。图像应以随机名称保存。我没有管理它,因为我不知道该怎么做。

我的实际代码也不起作用。我怎么解决这个问题?

<?php

$url = $_GET['url'];    // Website URL to Create Image
$name = $_GET['img'];   // Output Image Name
$command = "wkhtmltoimage --load-error-handling ignore";
$dir_img = "/var/www/vhosts/dl.andisblog.eu/httpdocs/screener/";     // Image files will be saved here
$ex_cmd = "$command $url " . $dir_img . $name;
$output = shell_exec($ex_cmd);
?>

编辑1:

我创建了一个新的php文件。

&#13;
&#13;
<?php

$url = str_replace('index.php','', $_SERVER['PHP_SELF']);
$url = str_replace($url,'',$_SERVER['REQUEST_URI']);
$url = explode('/',$url);
$name = array_shift($url);
$weburl = array_shift($url);

$command = "wkhtmltoimage --load-error-handling ignore";
$dir_img = "/var/www/vhosts/dl.andisblog.eu/andiundso.de/images";     // Image files will be saved here
$ex_cmd = "$command $weburl " . $dir_img . $name;
$output = shell_exec($ex_cmd);
echo "<img src=\"/images/$name\" >";  // comment this to disable image show on page

?>
&#13;
&#13;
&#13;

和这个.htaccess文件

&#13;
&#13;
RewriteEngine On
RewriteCond %{REQUEST_URI} /images/.+(gif|png|jpg)$
RewriteRule .* - [L]
RewriteRule ^.*$ index.php
&#13;
&#13;
&#13;

现在是网址:  http://domain.com/[imagename]/[site_url_without_http_prefix]

例如:  http://andiundso.de/ribingtestzero.jpg/bing.com

但是没有图像?

0 个答案:

没有答案