echo "pls wait some one have downloaded the file until he uploads you have to wait";
mytest.php:
Dbcon.php:
Code:
My database setup: CREATE TABLE IF NOT EXISTS `uploadedfiles` ( `ID` int(11) NOT NULL auto_increment, `filename` varchar(30) NOT NULL, `path` varchar(100) NOT NULL, `size` int(11) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=ascii AUTO_INCREMENT=1 ;
mytest.php:
Code:
<?php ?> <a href="filedownload.php?fileid=1&path=/./download/&filename=master 2000 thru 2005.xls"><b><u><font size =4>Download master 2000 thru 2005.xls file</b></u></font></a></center> <br> <a href="filedownload.php?fileid=2&path=/./download/&filename=master 2006 thru 2010.xls"><b><u><font size =4>Download master 2006 thru 2010.xls file</b></u></font></a></center>
Code:
<?php
$dbname = 'xxxx';
$link = mysql_connect("localhost","xxxx","xxxx") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");
?>
filedownload.php:
<?php
$file = $_REQUEST['filename'];
$file_id = $_REQUEST['fileid'];
$dir = $_REQUEST['path'];
include "Dbcon.php";
$rs = mysql_query("select * from uploadedfiles where fileid = $file_id and downloaded = 1");
if (mysql_affected_rows() == 0) {
mysql_query("update uploadedfiles set downloaded=1, downloadedtime = 'somedatetiem' where fileid = $file_id");
$dir="path";
if (isset($_REQUEST["filename"])) {
$file=$dir.$_REQUEST["filename"];
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment;" filename .basename($file));
readfile("$file");
} else {
echo "No file selected";
}
} else {
echo "pls wait some one have downloaded the file until he uploads you have to wait";
}
?>
Comment