Forum Moderators: coopster
What I am trying to create is:
Download Now link on one page that will look like this -<a href=”http://www.example.com/dl.php?urlid=absdef”>Download Now</a> and like
this- http://www.example.com/fileDownload/dl.php?filename=myFile.zip or like this - http://www.example.com/fileDownload/myFile.zip
I have been told that I need to create a table in My SQL DB that will contain urlid along with Original File Names and random names assigned to each file.
In my understanding it will probably look like the table below:
URL IDOriginal File Name Random File Name
001Personal-budget-calculator.xlsPersonalbudget
002Home-budget.xls Household
003Purchase-order.xls purchaseorder
How to do it all this is my question?
I believe that this is something that can be done since I have seen on many other web sites furthermore this can also be used to hide your affiliate ID links under some random name in urls.
[edited by: dreamcatcher at 6:55 am (utc) on Aug. 3, 2009]
[edit reason] use example.com. Thanks. [/edit]
This would probably be my first question: How can I make a connection between Random Names and Original file names in MySQL DB?
Thanks in advance
<?php
$encryptedFileName = $_GET['fileName'];
//now do your mysql connection
//the query would look something like this
//assuming your table is in the following structure
//id ¦ FileName ¦ Encryption
$query = "select FileName from TableOfFiles where Encryption = '{$encryptedFileName}';";
//do your mysql connection here and store the result as
//$fileName
//then set your header content
//take a note I don't know what the mime type for an
//xls file is, you will have to look on your server
//and make sure it is supported.
//alternatively you could try this
//header("Content-type: application/octet-stream");
//instead of header("Content-type: application/xls");
header("Content-type: application/xls");
header("Content-Disposition: attachment; filename=theNameYouWantHere.xls");
readfile("{$fileName}");
?>