This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
xd_2723548
Hi guys! Need help or some hint on downloading images in the backend of October CMS. I try to take screenshots by clicking on the button in the backend and link to the model. I try to take screenshots by clicking on the button in the backend and link to the model. I make a request through the Guzzle Client and get a response in the form of a binary code.
Model controller:
public function onMakeScreenShots() {
$url = post('url');
$client = new Client();
$request = $client->get('http://mini.s-shot.ru/' . '1280x800' . '/' . '1280' . '/' . '/jpeg/?' . $url);
$response = $request->getBody();
$screenshot_name = str_random(40) . '.jpg';
$file = (new File)->fromData($response, $screenshot_name);
/*$image = base64_encode($response);
$path='nodata...image/jpeg;base64,' . $image;*/
return [
'#FileUpload-formScreenshots-screenshots' => $file
];
}
Partial field:
xd_2723548
Update partial field button:
<button data-request="onMakeScreenshots" id="screenshots" data-request-data="url: 'http://site.ru'" class="btn btn-primary">Make screenshots</button>
1-2 of 2