I am trying to retrieve a PDF from a mysql database and then display it on the webpage. If I go into the MYSQL Workbench I can download the file and it displays correctly.
However, whenever I try to display it on the webpage it just gives me an empty grey screen. Here is my php file that tries to display it.
- Code: Select all
<?php
header("Content-Length: " . strlen($scanblob) );
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding:* binary \n");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
<html>
<title>Scan</title>
<body>
<?php echo ad($scanblob); ?>
<p>Debugging Purpose</p>
</body>
</html>
The next one is my controller that mediates the communication between my view and model.
- Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*************************************************display_image()********************************************************/
public function display_image($graphicid)
{
//Get the scanblob from the db
$this->load->model('mucs_model');
$image_info = $this->mucs_model->get_imageblob($graphicid);
$imageblob = $image_info['imageblob'];
$imageblob = addslashes($imageblob);
$imagedescription = $image_info['imagedescription'];
$data = array('imageblob' => $imageblob, 'imagedescription' => $imagedescription);
$this->load->view('image_view', $data);
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END display_image()@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The final code snippet is the one that communicates with the database.
- Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*************************************** get_scanblob($graphicid) ******************************************************/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function get_scanblob($graphicid)
{
$scan_query = mysql_query("SELECT scanblob, scandescription FROM scan WHERE scanid = (SELECT scanid FROM graphic WHERE graphicid = '$graphicid')");
$scan_info = mysql_fetch_array($scan_query);
return $scan_info;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END get_scanblob($graphicid)@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The table looks like this
CREATE TABLE scan(
scanid INTEGER NOT NULL AUTO_INCREMENT,
scantype TINYTEXT,
scanblob LONGBLOB,
scandescription VARCHAR(45),
scansize VARCHAR(45),
PRIMARY KEY(scanid));
I was wondering if there is anyway that someone could help point me in the right direction. Any help would be much appreciated! Thanks, Logan

