I want when I run the php file that is a picture taken from the site and will appear in the php file. The image should be saved with a random name. That I have not managed it because I do not know how to do it.
My actual code doesn't work too. How I can fix this?
<?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);
?>
Edit 1:
I have created a new php file.
<?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
?>
and this .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_URI} /images/.+(gif|png|jpg)$
RewriteRule .* - [L]
RewriteRule ^.*$ index.php
Now is the URL: http://domain.com/[imagename]/[site_url_without_http_prefix]
For example: http://andiundso.de/ribingtestzero.jpg/bing.com
But there gets no image?