Sending an Exported Report to the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.When the user exports a report in the viewer, the generated file can be sent back to the server and saved — handled in the
Save the exported file in PHP.
How it works. The export travels from the client viewer to the PHP event, so exported files can be archived on the server automatically.
onEndExportReport event.Save the exported file in PHP.
$viewer = new StiViewer();
$viewer->javascript->relativePath = '../';
$viewer->onEndExportReport = function (StiExportEventArgs $args) {
$reportName = $args->fileName . '.' . $args->fileExtension;
file_put_contents("../reports/$reportName", base64_decode($args->data));
return StiResult::getSuccess("Saved to '$reportName'.");
};
$viewer->handler->process();
$viewer->report = $report;onEndExportReport— fires server-side after an export;$args->dataholds the base64-encoded file.base64_decode($args->data)+file_put_contents— write the exported document to disk.StiResult::getSuccess/getError— return a message shown to the user after saving.
How it works. The export travels from the client viewer to the PHP event, so exported files can be archived on the server automatically.