Is there a better way to display images in HTML object with <img src='nufileget.php?i=CODE'> ?
Code: Select all
<?php.
$conf = dirname(__FILE__).'/nuconfig.php';
require($conf);
$code = $_GET['i'];
$sql = "SELECT sfi_json FROM zzzzsys_file WHERE sfi_code=:code";
$conStr = "mysql:host=$nuConfigDBHost;dbname=$nuConfigDBName;charset=utf8";
$this_db = new PDO($conStr, $nuConfigDBUser, $nuConfigDBPassword);
$this_db_obj = $this_db->prepare($sql);
$this_db_obj->execute(array(":code" => $code));
$this_db_obj->bindColumn(1, $data, PDO::PARAM_LOB);
$this_db_obj->fetch(PDO::FETCH_BOUND);
$obj = json_decode($data);
header("Content-Type:".$obj->{'type'});
$data = base64_decode($obj->{'file'});
$data = str_replace('data:'.$obj->{'type'}.';base64,', '', $data);
$data = base64_decode($data);
echo $data;
?>