<?php
include('database.php');
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$typeCode = $_GET['typeCode'];
$stmt = $conn->prepare("SELECT typeCode, fileName, fileContent FROM tbl_doc_files WHERE typeCode = ?");
$stmt->bind_param("s", $typeCode);
$stmt->execute();
$result = $stmt->get_result();
if ($result) {
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$fileName = $row['fileName'];
$fileContent = $row['fileContent'];
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
echo $fileContent;
} else {
echo "Attachment not found";
}
} else {
echo "Error executing the query: " . $conn->error;
}
$stmt->close();
$conn->close();
?>
i can retrieve the fileName but when i am trying to retrieve or display the fileContent it keeps loading. Also there are times that I can download the file but took like 15minutes before downloading.
the fileContent/attachment size was just 2MB.
is there any way?
thank you