`<?php 

$imageid=$_GET['asin'];

include ("connect.php");

$result_trends=$dbh->query("select * from expenses where autoid='".$imageid."'");
$row_trends=$result_trends->fetchObject();
$dave=$row_trends->attachment;

date_default_timezone_set('Africa/Kampala');

$filepath = 'uploads/' . $dave;

    if (file_exists($filepath)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . basename($filepath));
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize('uploads/' . $row_trends->attachment));
        readfile('uploads/' . $row_trends->attachment);
        // // Now update downloads count
        // $newCount = $file['downloads'] + 1;
        // $updateQuery = "UPDATE files SET downloads=$newCount WHERE id=$id";
        // mysqli_query($conn, $updateQuery);
        exit;
    }
?>