Click to See Complete Forum and Search --> : How to create dynamic links to download files


ahBird
08-14-2008, 03:01 AM
Hi guys,

I currently have a problem. How to create dynamic links to download files?

I currently have a uploader. This uploader does the following:
1) notes the filename
2) rename the filename with timestamp
3) store the name into a database
4) saves the file to a folder

Now for the problem;
I would like to create a page which will show the filename and a link to download the file right beside it without the admin(myself) to keep creating links. After countless of googling and book reference, I couldn't make any head start.

So the question:
How to make dynamic links with PHP and MySQL?
Should I store filename only or store filename and the file directory as well?
If so, how would I store the file directory?

Many thanks in advance, I have started PHP on books borrowed from library and the web. So my PHP and Mysql isn't that powerful. :p

copes
08-14-2008, 05:52 AM
Hi, i would do something like this:

$result = mysql_query('SELECT * FROM db_name_here');
while ($row = mysql_fetch_array($result)){
echo 'any divs etc the layout needs for each item';
echo '<a href="uploads/' . $row['filename'] . '">' . $row['name'] . '</a>';
}


You will need to add the file extension of the file unless the uploader you use records the extension in the name field of the database.

Hope it helps, should give you something to start on anyway.