I am trying to capture a screen and save it locally. When I run the code it shoots me an error message
Fatal error: Uncaught JonnyW\PhantomJs\Exception\NotWritableException: Output file is not writeable by PhantomJs:
This is my code
<?php
require 'vendor/autoload.php';
use JonnyW\PhantomJs\Client;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$client = Client::getInstance();
// $client->getEngine()->setPath('/usr/local/bin/phantomjs');
$width = 800;
$height = 600;
$top = 0;
$left = 0;
/**
* @see JonnyW\PhantomJs\Http\CaptureRequest
**/
$request = $client->getMessageFactory()->createCaptureRequest('http://jonnyw.me');
$request->setOutputFile('/screenshot/TEST.jpg');
$request->setViewportSize($width, $height);
$request->setCaptureDimensions($width, $height, $top, $left);
/**
* @see JonnyW\PhantomJs\Http\Response
**/
$response = $client->getMessageFactory()->createResponse();
// Send the request
$client->send($request, $response);
?>
And this is my form
<!DOCTYPE html>
<html>
<head>
<title>Upload Files to Crop/Take Screenshot of URL</title>
</head>
<body>
<h1>TAKE SCREENSHOT OF URL WITH phantomjs <span style="color:red">[NOT WORKING YET!!!!]</span></h1>
<form enctype="multipart/form-data" method="post" action="phantomjs.php">
<div class="row">
<label for="siteToCapture">Site to Capture</label><br />
https://www.<input type="input" name="siteToCapture" id="siteToCapture" />.com
</div>
<div class="row">
<input type="submit" value="SCAN" />
</div>
</form>
</body>
</html>
Another interesting thing I noticed was if I removed the '/' before screenshot/TEST.jpg I receive a blank page with no errors and still no screenshot.
I have also created the screenshot folder in the root directory.