KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

How to report file in Blob #1538

Open PP opened this topic on on Jul 20 - 1 comments

PP commented on Jul 20

Hi

I struggle to report a file like a PDF or a MS-Office file (xlsx, docx) in a tabular report. The report should either display the file (in case of a PDF) or offer a mechanism ( eg. url ) to download the file.

The files are stored in a mysql database as blob/clob. Are there any examples I could check for this.

Thank you Patrick

David Winterburn commented on Jul 21

Hi Patrick,

I would suggest listing the files in a table (or a list depending on your preference). Each item would be a link to page with a file id. For example:

<a href="path/to/getFile.php?fileID=fileID1">File ID 1</a>

Then in getFile.php you could retrieve the file content (blob) from your database and echo it to client:

<?php
$fileID = $_GET['fileID'];
list($name, $type, $size, $content) = getFileInfo($fileID);
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;
exit;

Let us know if you need further information. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None