Here is my code;
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<?php
$loader = require __DIR__ . '/vendor/autoload.php';
?>
<?php
use mikehaertl\wkhtmlto\Image;
$image = new \mikehaertl\wkhtmlto\Image('https://www.google.co.uk/search?q=what+is+the+time&oq=what+is+the+time&aqs=chrome.0.69i59j0l5.1536j0j4&sourceid=chrome&ie=UTF-8');
$image->setOptions(array(
'binary' => '/usr/local/bin/wkhtmltoimage',
'type' => 'png'
));
$image->saveAs('tmp/page.png');
$image = 'tmp/page.png';
$imageData = base64_encode(file_get_contents($image));
echo '<img src="data:image/png;base64,'.$imageData.'">';
?>
I would like the file page.png located in (tmp/page.png) to adopt a random filename every time this script runs, I believe I need to do something like;
$filename = uniqid(rand(), true) . '.png';
Then replace;
$image->saveAs('tmp/page.png');
With;
$image->saveAs('tmp/$filename');
But I am not too sure how I lay that out when it comes to ( . / ' / " ) etc.. Thanks.