Location: PHPKode > projects > Druid Defect Control > defectcontrol_0.9.4/tts/getattachment.php
<?php //ob_start();

require_once 'database.php'; 
require_once 'errors.php';
require_once 'config.php';

    // connect to the db
    ttdb_connect($connection);

    $res = ttdb_execQuery($connection,"select * from attachments where iid = $iidatt;");
    $fields = ttdb_getArray($res);
    
    if (!is_array($fields)) {
        tter_errorWithBackButton("Attachment not found ($iidatt)");
        exit;    
    }

    
    $filename = ATTACHMENTS_BASE_DIR."{$fields['iiddefect']}/{$fields['sfile']}";

    //echo $filename;

    $len = filesize($filename);

    //echo "Content-type: {$fields['smimetype']}";
    //echo "Content-Length: $len";
    //echo("Content-Disposition: inline; filename={$fields['sfile']}");
    
    header("Content-type: {$fields['smimetype']}");
    header("Content-Length: $len");
    header("Content-Disposition: inline; filename={$fields['sfile']}");
    readfile($filename);

    ttdb_close($connection);
    
    //header("Location: visualize.php?iddefect=$iddefect");
    //ob_end_flush();
?>
Return current item: Druid Defect Control