<?php
if($_GET['id']){
$filename = "IMAGES/NEWS/".$_GET['id']; // file to be downloaded
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");
/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
<?php ob_start(); ?>
<?php require_once('Connections/connashimori.php'); ?>
<?php include("check.php"); ?>
<?php include("header.php");?>
<?php
if($_GET['id']){
$filename = "IMAGES/NEWS/".$_GET['id']; // file to be downloaded
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
// force download dialog
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-type: application/pdf");
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");
/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
}
echo'<br>';
echo'<table border="1" width="1000" align="center" cellpadding="0" cellspacing="0" bordercolor="lightblue">';
echo'<tr>';
echo'<td align="center" width="70%" bgcolor="lightblue">FileName</td>';
echo'<td align="center" width="15%" bgcolor="lightblue">Size</td>';
echo'<td align="center" width="15%" bgcolor="lightblue">Upload Date</td>';
echo'</tr>';
$sqlSelectFile = "select * from news where year(created) = '2013' order by created DESC";
$querySelectFile = mysql_query($sqlSelectFile);
while($resultSelectFile = mysql_fetch_array($querySelectFile)){
echo'<tr>';
echo'<td><a href="download.php?id='.$resultSelectFile['pdf'].'">'.$resultSelectFile['headline'].'</td>';
echo'<td align="center">'.number_format(((filesize("IMAGES/NEWS/".$resultSelectFile['pdf'])/1024)/1024),2).' MB. </td>';
echo'<td align="center">'.$resultSelectFile['created'].'</td>';
echo'</tr>';
}
echo'</table>';
?>