This example shows how to send and save an exported report on the PHP server side. First, you need to add the Stimulsoft libraries:
<?php
require_once 'vendor/autoload.php';
?>

Next, create handler, apply options to the viewer and enable onEndExportReport event:
<?php
$handler = new \Stimulsoft\StiHandler();

$handler->renderHtml();

$options = new \Stimulsoft\Viewer\StiViewerOptions();
$options->appearance->fullScreenMode = true;

$viewer = new \Stimulsoft\Viewer\StiViewer($options);

$viewer->onEndExportReport = true;

$report = new \Stimulsoft\Report\StiReport();
$report->loadFile('reports/SimpleList.mrt');
$viewer->report = $report;
?>

Finally, use onEndExportReport event on the server-side:
$handler->onEndExportReport = function ($args)
{
	// Getting the file name with the extension.
	$reportName = $args->fileName . '.' . $args->fileExtension;

	// By default, the exported file is saved to the 'reports' folder.
	// You can change this behavior if required.
	file_put_contents('reports/' . $reportName, base64_decode($args->data));

	//return StiResult::success();
	return StiResult::success("The exported report is saved successfully as $reportName");
	//return StiResult::error('An error occurred while exporting the report.');
};

In the screenshot below you can see the result of the sample code:

Sending an Exported Report to the Server-Side

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.